diff --git a/CHANGELOG.md b/CHANGELOG.md index 20b52c6a..94063fcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ Notable FlexDoc product releases are recorded here. Detailed release notes remain under `docs/releases/` and are linked from each entry. +## Unreleased + +- An implemented route that OpenAPI does not document fails `flexdoc validate` when runtime discovery is complete, and the failure names the method and path. Partial discovery keeps that finding a warning. `runtimeIntelligence.acknowledgedUndocumented` omits operations that are intentionally absent from the contract. Those routes stay in the runtime route list, and `summary.runtime` counts only `matched + runtimeOnly`. +- Opening that finding shows the registered route. It is not treated as an OpenAPI operation. + ## 3.4.0 — 3.3.x hardening package release Package semver is independent from internal product-milestone labels: **3.4.0** publishes the completed 3.3.x hardening stack. diff --git a/adapters/elixir/assets/flexdoc.standalone.js b/adapters/elixir/assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/elixir/assets/flexdoc.standalone.js +++ b/adapters/elixir/assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/go/assets/flexdoc.standalone.js b/adapters/go/assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/go/assets/flexdoc.standalone.js +++ b/adapters/go/assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/php/assets/flexdoc.standalone.js b/adapters/php/assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/php/assets/flexdoc.standalone.js +++ b/adapters/php/assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js b/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js +++ b/adapters/python/src/prauga_flexdoc/_assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/ruby/assets/flexdoc.standalone.js b/adapters/ruby/assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/ruby/assets/flexdoc.standalone.js +++ b/adapters/ruby/assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/rust-actix/assets/flexdoc.standalone.js b/adapters/rust-actix/assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/rust-actix/assets/flexdoc.standalone.js +++ b/adapters/rust-actix/assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/adapters/rust/assets/flexdoc.standalone.js b/adapters/rust/assets/flexdoc.standalone.js index 62d6cadf..3efc5433 100644 --- a/adapters/rust/assets/flexdoc.standalone.js +++ b/adapters/rust/assets/flexdoc.standalone.js @@ -1,65 +1,65 @@ -var FlexDocStandaloneBundle=(function(As){"use strict";var wg=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Sg(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var md={exports:{}},la={};var Ag;function EA(){if(Ag)return la;Ag=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function n(r,s,a){var c=null;if(a!==void 0&&(c=""+a),s.key!==void 0&&(c=""+s.key),"key"in s){a={};for(var u in s)u!=="key"&&(a[u]=s[u])}else a=s;return s=a.ref,{$$typeof:t,type:r,key:c,ref:s!==void 0?s:null,props:a}}return la.Fragment=e,la.jsx=n,la.jsxs=n,la}var kg;function OA(){return kg||(kg=1,md.exports=EA()),md.exports}var p=OA(),gd={exports:{}},aa={},yd={exports:{}},bd={};var Cg;function MA(){return Cg||(Cg=1,(function(t){function e(L,Q){var oe=L.length;L.push(Q);e:for(;0>>1,ve=L[ue];if(0>>1;ues(he,oe))nes(ke,he)?(L[ue]=ke,L[ne]=oe,ue=ne):(L[ue]=he,L[z]=oe,ue=z);else if(nes(ke,oe))L[ue]=ke,L[ne]=oe,ue=ne;else break e}}return Q}function s(L,Q){var oe=L.sortIndex-Q.sortIndex;return oe!==0?oe:L.id-Q.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,O=!1,D=typeof setTimeout=="function"?setTimeout:null,E=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function M(L){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=L)r(h),Q.sortIndex=Q.expirationTime,e(f,Q);else break;Q=n(h)}}function _(L){if(C=!1,M(L),!A)if(n(f)!==null)A=!0,q||(q=!0,W());else{var Q=n(h);Q!==null&&fe(_,Q.startTime-L)}}var q=!1,R=-1,J=5,U=-1;function B(){return O?!0:!(t.unstable_now()-UL&&B());){var ue=b.callback;if(typeof ue=="function"){b.callback=null,v=b.priorityLevel;var ve=ue(b.expirationTime<=L);if(L=t.unstable_now(),typeof ve=="function"){b.callback=ve,M(L),Q=!0;break t}b===n(f)&&r(f),M(L)}else r(f);b=n(f)}if(b!==null)Q=!0;else{var T=n(h);T!==null&&fe(_,T.startTime-L),Q=!1}}break e}finally{b=null,v=oe,w=!1}Q=void 0}}finally{Q?W():q=!1}}}var W;if(typeof j=="function")W=function(){j(K)};else if(typeof MessageChannel<"u"){var ye=new MessageChannel,me=ye.port2;ye.port1.onmessage=K,W=function(){me.postMessage(null)}}else W=function(){D(K,0)};function fe(L,Q){R=D(function(){L(t.unstable_now())},Q)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(L){L.callback=null},t.unstable_forceFrameRate=function(L){0>L||125ue?(L.sortIndex=oe,e(h,L),n(f)===null&&L===n(h)&&(C?(E(R),R=-1):C=!0,fe(_,oe-ue))):(L.sortIndex=ve,e(f,L),A||w||(A=!0,q||(q=!0,W()))),L},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(L){var Q=v;return function(){var oe=v;v=Q;try{return L.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,O={};function D(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function E(){}E.prototype=D.prototype;function j(T,z,he){this.props=T,this.context=z,this.refs=O,this.updater=he||A}var M=j.prototype=new E;M.constructor=j,C(M,D.prototype),M.isPureReactComponent=!0;var _=Array.isArray;function q(){}var R={H:null,A:null,T:null,S:null},J=Object.prototype.hasOwnProperty;function U(T,z,he){var ne=he.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:he}}function B(T,z){return U(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function W(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(he){return z[he]})}var ye=/\/+/g;function me(T,z){return typeof T=="object"&&T!==null&&T.key!=null?W(""+T.key):z.toString(36)}function fe(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(q,q):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function L(T,z,he,ne,ke){var _e=typeof T;(_e==="undefined"||_e==="boolean")&&(T=null);var $e=!1;if(T===null)$e=!0;else switch(_e){case"bigint":case"string":case"number":$e=!0;break;case"object":switch(T.$$typeof){case t:case e:$e=!0;break;case g:return $e=T._init,L($e(T._payload),z,he,ne,ke)}}if($e)return ke=ke(T),$e=ne===""?"."+me(T,0):ne,_(ke)?(he="",$e!=null&&(he=$e.replace(ye,"$&/")+"/"),L(ke,z,he,"",function(Ie){return Ie})):ke!=null&&(K(ke)&&(ke=B(ke,he+(ke.key==null||T&&T.key===ke.key?"":(""+ke.key).replace(ye,"$&/")+"/")+$e)),z.push(ke)),1;$e=0;var Pe=ne===""?".":ne+":";if(_(T))for(var Ke=0;Ke"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1ve||(i.current=ue[ve],ue[ve]=null,ve--)}function he(i,l){ve++,ue[ve]=i.current,i.current=l}var ne=T(null),ke=T(null),_e=T(null),$e=T(null);function Pe(i,l){switch(he(_e,l),he(ke,i),he(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),he(ne,i)}function Ke(){z(ne),z(ke),z(_e)}function Ie(i){i.memoizedState!==null&&he($e,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(he(ke,i),he(ne,o))}function ut(i){ke.current===i&&(z(ne),z(ke)),$e.current===i&&(z($e),Oo._currentValue=oe)}var Rt,Ce;function Ee(i){if(Rt===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);Rt=l&&l[1]||"",Ce=-1>>1,Se=q[he];if(0>>1;hes(me,oe))nes(Ce,me)?(q[he]=Ce,q[ne]=oe,he=ne):(q[he]=me,q[z]=oe,he=z);else if(nes(Ce,oe))q[he]=Ce,q[ne]=oe,he=ne;else break e}}return J}function s(q,J){var oe=q.sortIndex-J.sortIndex;return oe!==0?oe:q.id-J.id}if(t.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var a=performance;t.unstable_now=function(){return a.now()}}else{var c=Date,u=c.now();t.unstable_now=function(){return c.now()-u}}var f=[],h=[],g=1,b=null,v=3,w=!1,A=!1,C=!1,E=!1,D=typeof setTimeout=="function"?setTimeout:null,O=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;function R(q){for(var J=n(h);J!==null;){if(J.callback===null)r(h);else if(J.startTime<=q)r(h),J.sortIndex=J.expirationTime,e(f,J);else break;J=n(h)}}function _(q){if(C=!1,R(q),!A)if(n(f)!==null)A=!0,L||(L=!0,ee());else{var J=n(h);J!==null&&ge(_,J.startTime-q)}}var L=!1,M=-1,G=5,Y=-1;function B(){return E?!0:!(t.unstable_now()-Yq&&B());){var he=b.callback;if(typeof he=="function"){b.callback=null,v=b.priorityLevel;var Se=he(b.expirationTime<=q);if(q=t.unstable_now(),typeof Se=="function"){b.callback=Se,R(q),J=!0;break t}b===n(f)&&r(f),R(q)}else r(f);b=n(f)}if(b!==null)J=!0;else{var T=n(h);T!==null&&ge(_,T.startTime-q),J=!1}}break e}finally{b=null,v=oe,w=!1}J=void 0}}finally{J?ee():L=!1}}}var ee;if(typeof j=="function")ee=function(){j(K)};else if(typeof MessageChannel<"u"){var be=new MessageChannel,ce=be.port2;be.port1.onmessage=K,ee=function(){ce.postMessage(null)}}else ee=function(){D(K,0)};function ge(q,J){M=D(function(){q(t.unstable_now())},J)}t.unstable_IdlePriority=5,t.unstable_ImmediatePriority=1,t.unstable_LowPriority=4,t.unstable_NormalPriority=3,t.unstable_Profiling=null,t.unstable_UserBlockingPriority=2,t.unstable_cancelCallback=function(q){q.callback=null},t.unstable_forceFrameRate=function(q){0>q||125he?(q.sortIndex=oe,e(h,q),n(f)===null&&q===n(h)&&(C?(O(M),M=-1):C=!0,ge(_,oe-he))):(q.sortIndex=Se,e(f,q),A||w||(A=!0,L||(L=!0,ee()))),q},t.unstable_shouldYield=B,t.unstable_wrapCallback=function(q){var J=v;return function(){var oe=v;v=J;try{return q.apply(this,arguments)}finally{v=oe}}}})(bd)),bd}var Ng;function RA(){return Ng||(Ng=1,yd.exports=MA()),yd.exports}var xd={exports:{}},et={};var Tg;function DA(){if(Tg)return et;Tg=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.consumer"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),b=Symbol.for("react.activity"),v=Symbol.iterator;function w(T){return T===null||typeof T!="object"?null:(T=v&&T[v]||T["@@iterator"],typeof T=="function"?T:null)}var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,E={};function D(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}D.prototype.isReactComponent={},D.prototype.setState=function(T,z){if(typeof T!="object"&&typeof T!="function"&&T!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,T,z,"setState")},D.prototype.forceUpdate=function(T){this.updater.enqueueForceUpdate(this,T,"forceUpdate")};function O(){}O.prototype=D.prototype;function j(T,z,me){this.props=T,this.context=z,this.refs=E,this.updater=me||A}var R=j.prototype=new O;R.constructor=j,C(R,D.prototype),R.isPureReactComponent=!0;var _=Array.isArray;function L(){}var M={H:null,A:null,T:null,S:null},G=Object.prototype.hasOwnProperty;function Y(T,z,me){var ne=me.ref;return{$$typeof:t,type:T,key:z,ref:ne!==void 0?ne:null,props:me}}function B(T,z){return Y(T.type,z,T.props)}function K(T){return typeof T=="object"&&T!==null&&T.$$typeof===t}function ee(T){var z={"=":"=0",":":"=2"};return"$"+T.replace(/[=:]/g,function(me){return z[me]})}var be=/\/+/g;function ce(T,z){return typeof T=="object"&&T!==null&&T.key!=null?ee(""+T.key):z.toString(36)}function ge(T){switch(T.status){case"fulfilled":return T.value;case"rejected":throw T.reason;default:switch(typeof T.status=="string"?T.then(L,L):(T.status="pending",T.then(function(z){T.status==="pending"&&(T.status="fulfilled",T.value=z)},function(z){T.status==="pending"&&(T.status="rejected",T.reason=z)})),T.status){case"fulfilled":return T.value;case"rejected":throw T.reason}}throw T}function q(T,z,me,ne,Ce){var Re=typeof T;(Re==="undefined"||Re==="boolean")&&(T=null);var qe=!1;if(T===null)qe=!0;else switch(Re){case"bigint":case"string":case"number":qe=!0;break;case"object":switch(T.$$typeof){case t:case e:qe=!0;break;case g:return qe=T._init,q(qe(T._payload),z,me,ne,Ce)}}if(qe)return Ce=Ce(T),qe=ne===""?"."+ce(T,0):ne,_(Ce)?(me="",qe!=null&&(me=qe.replace(be,"$&/")+"/"),q(Ce,z,me,"",function(Be){return Be})):Ce!=null&&(K(Ce)&&(Ce=B(Ce,me+(Ce.key==null||T&&T.key===Ce.key?"":(""+Ce.key).replace(be,"$&/")+"/")+qe)),z.push(Ce)),1;qe=0;var He=ne===""?".":ne+":";if(_(T))for(var Je=0;Je"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),wd.exports=_A(),wd.exports}var Mg;function qA(){if(Mg)return aa;Mg=1;var t=RA(),e=vd(),n=LA();function r(i){var l="https://react.dev/errors/"+i;if(1Se||(i.current=he[Se],he[Se]=null,Se--)}function me(i,l){Se++,he[Se]=i.current,i.current=l}var ne=T(null),Ce=T(null),Re=T(null),qe=T(null);function He(i,l){switch(me(Re,l),me(Ce,i),me(ne,null),l.nodeType){case 9:case 11:i=(i=l.documentElement)&&(i=i.namespaceURI)?J2(i):0;break;default:if(i=l.tagName,l=l.namespaceURI)l=J2(l),i=Q2(l,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}z(ne),me(ne,i)}function Je(){z(ne),z(Ce),z(Re)}function Be(i){i.memoizedState!==null&&me(qe,i);var l=ne.current,o=Q2(l,i.type);l!==o&&(me(Ce,i),me(ne,o))}function dt(i){Ce.current===i&&(z(ne),z(Ce)),qe.current===i&&(z(qe),Oo._currentValue=oe)}var At,yt;function Ge(i){if(At===void 0)try{throw Error()}catch(o){var l=o.stack.trim().match(/\n( *(at )?)/);At=l&&l[1]||"",yt=-1)":-1m||$[d]!==te[m]){var de=` -`+$[d].replace(" at new "," at ");return i.displayName&&de.includes("")&&(de=de.replace("",i.displayName)),de}while(1<=d&&0<=m);break}}}finally{G=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ee(o):""}function Ne(i,l){switch(i.tag){case 26:case 27:case 5:return Ee(i.type);case 16:return Ee("Lazy");case 13:return i.child!==l&&l!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Se(i.type,!1);case 11:return Se(i.type.render,!1);case 1:return Se(i.type,!0);case 31:return Ee("Activity");default:return""}}function Re(i){try{var l="",o=null;do l+=Ne(i,o),o=i,i=i.return;while(i);return l}catch(d){return` +`);for(m=d=0;d<$.length&&!$[d].includes("DetermineComponentFrameRoot");)d++;for(;mm||$[d]!==te[m]){var fe=` +`+$[d].replace(" at new "," at ");return i.displayName&&fe.includes("")&&(fe=fe.replace("",i.displayName)),fe}while(1<=d&&0<=m);break}}}finally{Q=!1,Error.prepareStackTrace=o}return(o=i?i.displayName||i.name:"")?Ge(o):""}function ve(i,l){switch(i.tag){case 26:case 27:case 5:return Ge(i.type);case 16:return Ge("Lazy");case 13:return i.child!==l&&l!==null?Ge("Suspense Fallback"):Ge("Suspense");case 19:return Ge("SuspenseList");case 0:case 15:return re(i.type,!1);case 11:return re(i.type.render,!1);case 1:return re(i.type,!0);case 31:return Ge("Activity");default:return""}}function Ne(i){try{var l="",o=null;do l+=ve(i,o),o=i,i=i.return;while(i);return l}catch(d){return` Error generating stack: `+d.message+` -`+d.stack}}var Ge=Object.prototype.hasOwnProperty,st=t.unstable_scheduleCallback,Et=t.unstable_cancelCallback,ti=t.unstable_shouldYield,Tn=t.unstable_requestPaint,ht=t.unstable_now,ni=t.unstable_getCurrentPriorityLevel,Vn=t.unstable_ImmediatePriority,qn=t.unstable_UserBlockingPriority,St=t.unstable_NormalPriority,x=t.unstable_LowPriority,V=t.unstable_IdlePriority,pe=t.log,ae=t.unstable_setDisableYieldValue,X=null,k=null;function F(i){if(typeof pe=="function"&&ae(i),k&&typeof k.setStrictMode=="function")try{k.setStrictMode(X,i)}catch{}}var Z=Math.clz32?Math.clz32:ce,xe=Math.log,P=Math.LN2;function ce(i){return i>>>=0,i===0?32:31-(xe(i)/P|0)|0}var le=256,we=262144,Oe=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Be(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Oe;return Oe<<=1,(Oe&62914560)===0&&(Oe=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-Z(l)+m|o<it?(ft=He,He=null):ft=He.sibling;var xt=ie(Y,He,ee[it],ge);if(xt===null){He===null&&(He=ft);break}i&&He&&xt.alternate===null&&l(Y,He),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,He=ft}if(it===ee.length)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;itit?(ft=He,He=null):ft=He.sibling;var Ss=ie(Y,He,xt.value,ge);if(Ss===null){He===null&&(He=ft);break}i&&He&&Ss.alternate===null&&l(Y,He),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,He=ft}if(xt.done)return o(Y,He),pt&&gr(Y,it),Fe;if(He===null){for(;!xt.done;it++,xt=ee.next())xt=be(Y,xt.value,ge),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return pt&&gr(Y,it),Fe}for(He=d(He);!xt.done;it++,xt=ee.next())xt=se(He,Y,it,xt.value,ge),xt!==null&&(i&&xt.alternate!==null&&He.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&He.forEach(function(uD){return l(Y,uD)}),pt&&gr(Y,it),Fe}function Tt(Y,H,ee,ge){if(typeof ee=="object"&&ee!==null&&ee.type===C&&ee.key===null&&(ee=ee.props.children),typeof ee=="object"&&ee!==null){switch(ee.$$typeof){case w:e:{for(var Fe=ee.key;H!==null;){if(H.key===Fe){if(Fe=ee.type,Fe===C){if(H.tag===7){o(Y,H.sibling),ge=m(H,ee.props.children),ge.return=Y,Y=ge;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===J&&Ks(Fe)===H.type){o(Y,H.sibling),ge=m(H,ee.props),lo(ge,ee),ge.return=Y,Y=ge;break e}o(Y,H);break}else l(Y,H);H=H.sibling}ee.type===C?(ge=Us(ee.props.children,Y.mode,ge,ee.key),ge.return=Y,Y=ge):(ge=yu(ee.type,ee.key,ee.props,null,Y.mode,ge),lo(ge,ee),ge.return=Y,Y=ge)}return S(Y);case A:e:{for(Fe=ee.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===ee.containerInfo&&H.stateNode.implementation===ee.implementation){o(Y,H.sibling),ge=m(H,ee.children||[]),ge.return=Y,Y=ge;break e}else{o(Y,H);break}else l(Y,H);H=H.sibling}ge=Ip(ee,Y.mode,ge),ge.return=Y,Y=ge}return S(Y);case J:return ee=Ks(ee),Tt(Y,H,ee,ge)}if(fe(ee))return qe(Y,H,ee,ge);if(W(ee)){if(Fe=W(ee),typeof Fe!="function")throw Error(r(150));return ee=Fe.call(ee),Xe(Y,H,ee,ge)}if(typeof ee.then=="function")return Tt(Y,H,ku(ee),ge);if(ee.$$typeof===j)return Tt(Y,H,vu(Y,ee),ge);Cu(Y,ee)}return typeof ee=="string"&&ee!==""||typeof ee=="number"||typeof ee=="bigint"?(ee=""+ee,H!==null&&H.tag===6?(o(Y,H.sibling),ge=m(H,ee),ge.return=Y,Y=ge):(o(Y,H),ge=$p(ee,Y.mode,ge),ge.return=Y,Y=ge),S(Y)):o(Y,H)}return function(Y,H,ee,ge){try{so=0;var Fe=Tt(Y,H,ee,ge);return Vl=null,Fe}catch(He){if(He===Ul||He===Su)throw He;var bt=li(29,He,null,Y.mode);return bt.lanes=ge,bt.return=Y,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(vt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var de=i.alternate;de!==null&&(de=de.updateQueue,N=de.lastBaseUpdate,N!==S&&(N===null?de.firstBaseUpdate=te:N.next=te,de.lastBaseUpdate=$))}if(y!==null){var be=m.baseState;S=0,de=te=$=null,N=y;do{var ie=N.lane&-536870913,se=ie!==N.lane;if(se?(dt&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),de!==null&&(de=de.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var qe=i,Xe=N;ie=l;var Tt=o;switch(Xe.tag){case 1:if(qe=Xe.payload,typeof qe=="function"){be=qe.call(Tt,be,ie);break e}be=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=Xe.payload,ie=typeof qe=="function"?qe.call(Tt,be,ie):qe,ie==null)break e;be=b({},be,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,se&&(i.flags|=8192),se=m.callbacks,se===null?m.callbacks=[ie]:se.push(ie))}else se={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},de===null?(te=de=se,$=be):de=de.next=se,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;se=N,N=se.next,se.next=null,m.lastBaseUpdate=se,m.shared.pending=null}}while(!0);de===null&&($=be),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=de,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=be}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=L.T,N={};L.T=N,xm(i,!1,l,o);try{var $=m(),te=L.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var de=ZR($,d);ho(i,l,de,di(i))}else ho(i,l,d,di(i))}catch(be){ho(i,l,{then:function(){},status:"rejected",reason:be},di())}finally{Q.p=y,S!==null&&N.types!==null&&(S.types=N.types),L.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Ot===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){F(!0);try{i()}finally{F(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){F(!0);try{o(l)}finally{F(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(pt){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Ot===null)throw Error(r(349));(dt&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Ot.identifierPrefix;if(pt){var o=Zi,d=Wi;o=(d&~(1<<32-Z(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=_e.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Ke(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return he(Kt,Kt.current&1|2),pt&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ht()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!pt)return qt(l),null}else 2*ht()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ht(),i.sibling=null,o=Kt.current,he(Kt,m?o&1|2:o&1),pt&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Ke(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return ut(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Ke(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Ke();break;case 26:case 27:case 5:ut(l);break;case 4:Ke();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){kt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(de){kt(m,$,de)}}}d=d.next}while(d!==y)}}catch(de){kt(l,l.return,de)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){kt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){kt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){kt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){kt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){kt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){kt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){kt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){kt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,de=0,be=i,ie=null;t:for(;;){for(var se;be!==o||m!==0&&be.nodeType!==3||(N=S+m),be!==y||d!==0&&be.nodeType!==3||($=S+d),be.nodeType===3&&(S+=be.nodeValue.length),(se=be.firstChild)!==null;)ie=be,be=se;for(;;){if(be===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++de===d&&($=S),(se=be.nextSibling)!==null)break;be=ie,ie=be.parentNode}be=se}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NTt&&(S=Tt,Tt=Xe,Xe=S);var Y=mw(N,Xe),H=mw(N,Tt);if(Y&&H&&(se.rangeCount!==1||se.anchorNode!==Y.node||se.anchorOffset!==Y.offset||se.focusNode!==H.node||se.focusOffset!==H.offset)){var ee=be.createRange();ee.setStart(Y.node,Y.offset),se.removeAllRanges(),Xe>Tt?(se.addRange(ee),se.extend(H.node,H.offset)):(ee.setEnd(H.node,H.offset),se.addRange(ee))}}}}for(be=[],se=N;se=se.parentNode;)se.nodeType===1&&be.push({element:se,left:se.scrollLeft,top:se.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,L.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(vt&6)!==0)throw Error(r(331));var N=vt;if(vt|=4,g2(y.current),h2(y,y.current,S,o),vt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{Q.p=m,L.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function kt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Ot===i&&(dt&o)===o&&(Ut===4||Ut===3&&(dt&62914560)===dt&&300>ht()-Fu?(vt&2)===0&&Zl(i,0):zm|=o,Ql===dt&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return st(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-Z(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=dt,y=Be(d,d===Ot?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ht(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var de=$.transferSize,be=$.initiatorType;de&&X2(be)&&($=$.responseEnd,S+=de*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,de){$.onload=te,$.onerror=de}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=_e.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const lt=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=lt("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=lt("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=lt("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=lt("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=lt("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=lt("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=lt("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=lt("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=lt("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=lt("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=lt("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=lt("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=lt("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=lt("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=lt("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=lt("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=lt("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=lt("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=lt("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=lt("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=lt("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=lt("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=lt("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=lt("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=lt("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=lt("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=lt("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=lt("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=lt("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=lt("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=lt("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=lt("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=lt("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=lt("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=lt("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=lt("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=lt("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=lt("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;h>>=0,i===0?32:31-(we(i)/F|0)|0}var ae=256,Ae=262144,Ee=4194304;function Te(i){var l=i&42;if(l!==0)return l;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function Le(i,l,o){var d=i.pendingLanes;if(d===0)return 0;var m=0,y=i.suspendedLanes,S=i.pingedLanes;i=i.warmLanes;var N=d&134217727;return N!==0?(d=N&~y,d!==0?m=Te(d):(S&=N,S!==0?m=Te(S):o||(o=N&~i,o!==0&&(m=Te(o))))):(N=d&~y,N!==0?m=Te(N):S!==0?m=Te(S):o||(o=d&~i,o!==0&&(m=Te(o)))),m===0?0:l!==0&&l!==m&&(l&y)===0&&(y=m&-m,o=l&-l,y>=o||y===32&&(o&4194048)!==0)?l:m}function ze(i,l){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&l)===0}function Ve(i,l){switch(i){case 1:case 2:case 4:case 8:case 64:return l+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return l+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Dt(){var i=Ee;return Ee<<=1,(Ee&62914560)===0&&(Ee=4194304),i}function Fn(i){for(var l=[],o=0;31>o;o++)l.push(i);return l}function jn(i,l){i.pendingLanes|=l,l!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function Va(i,l,o,d,m,y){var S=i.pendingLanes;i.pendingLanes=o,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=o,i.entangledLanes&=o,i.errorRecoveryDisabledLanes&=o,i.shellSuspendCounter=0;var N=i.entanglements,$=i.expirationTimes,te=i.hiddenUpdates;for(o=S&~o;0"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var sR=/[\n"\\]/g;function vi(i){return i.replace(sR,function(l){return"\\"+l.charCodeAt(0).toString(16)+" "})}function mp(i,l,o,d,m,y,S,N){i.name="",S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"?i.type=S:i.removeAttribute("type"),l!=null?S==="number"?(l===0&&i.value===""||i.value!=l)&&(i.value=""+On(l)):i.value!==""+On(l)&&(i.value=""+On(l)):S!=="submit"&&S!=="reset"||i.removeAttribute("value"),l!=null?gp(i,S,On(l)):o!=null?gp(i,S,On(o)):d!=null&&i.removeAttribute("value"),m==null&&y!=null&&(i.defaultChecked=!!y),m!=null&&(i.checked=m&&typeof m!="function"&&typeof m!="symbol"),N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"?i.name=""+On(N):i.removeAttribute("name")}function F1(i,l,o,d,m,y,S,N){if(y!=null&&typeof y!="function"&&typeof y!="symbol"&&typeof y!="boolean"&&(i.type=y),l!=null||o!=null){if(!(y!=="submit"&&y!=="reset"||l!=null)){pp(i);return}o=o!=null?""+On(o):"",l=l!=null?""+On(l):o,N||l===i.value||(i.value=l),i.defaultValue=l}d=d??m,d=typeof d!="function"&&typeof d!="symbol"&&!!d,i.checked=N?i.checked:!!d,i.defaultChecked=!!d,S!=null&&typeof S!="function"&&typeof S!="symbol"&&typeof S!="boolean"&&(i.name=S),pp(i)}function gp(i,l,o){l==="number"&&su(i.ownerDocument)===i||i.defaultValue===""+o||(i.defaultValue=""+o)}function Tl(i,l,o,d){if(i=i.options,l){l={};for(var m=0;m"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),wp=!1;if(pr)try{var Ka={};Object.defineProperty(Ka,"passive",{get:function(){wp=!0}}),window.addEventListener("test",Ka,Ka),window.removeEventListener("test",Ka,Ka)}catch{wp=!1}var es=null,Sp=null,au=null;function Q1(){if(au)return au;var i,l=Sp,o=l.length,d,m="value"in es?es.value:es.textContent,y=m.length;for(i=0;i=Ja),iw=" ",rw=!1;function sw(i,l){switch(i){case"keyup":return DR.indexOf(l.keyCode)!==-1;case"keydown":return l.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lw(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var Ml=!1;function LR(i,l){switch(i){case"compositionend":return lw(l);case"keypress":return l.which!==32?null:(rw=!0,iw);case"textInput":return i=l.data,i===iw&&rw?null:i;default:return null}}function qR(i,l){if(Ml)return i==="compositionend"||!Tp&&sw(i,l)?(i=Q1(),au=Sp=es=null,Ml=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(l.ctrlKey||l.altKey||l.metaKey)||l.ctrlKey&&l.altKey){if(l.char&&1=l)return{node:o,offset:l-i};i=d}e:{for(;o;){if(o.nextSibling){o=o.nextSibling;break e}o=o.parentNode}o=void 0}o=pw(o)}}function gw(i,l){return i&&l?i===l?!0:i&&i.nodeType===3?!1:l&&l.nodeType===3?gw(i,l.parentNode):"contains"in i?i.contains(l):i.compareDocumentPosition?!!(i.compareDocumentPosition(l)&16):!1:!1}function yw(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var l=su(i.document);l instanceof i.HTMLIFrameElement;){try{var o=typeof l.contentWindow.location.href=="string"}catch{o=!1}if(o)i=l.contentWindow;else break;l=su(i.document)}return l}function Op(i){var l=i&&i.nodeName&&i.nodeName.toLowerCase();return l&&(l==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||l==="textarea"||i.contentEditable==="true")}var FR=pr&&"documentMode"in document&&11>=document.documentMode,Rl=null,Mp=null,eo=null,Rp=!1;function bw(i,l,o){var d=o.window===o?o.document:o.nodeType===9?o:o.ownerDocument;Rp||Rl==null||Rl!==su(d)||(d=Rl,"selectionStart"in d&&Op(d)?d={start:d.selectionStart,end:d.selectionEnd}:(d=(d.ownerDocument&&d.ownerDocument.defaultView||window).getSelection(),d={anchorNode:d.anchorNode,anchorOffset:d.anchorOffset,focusNode:d.focusNode,focusOffset:d.focusOffset}),eo&&Za(eo,d)||(eo=d,d=ed(Mp,"onSelect"),0>=S,m-=S,Wi=1<<32-W(l)+m|o<it?(ut=Ie,Ie=null):ut=Ie.sibling;var xt=ie(P,Ie,Z[it],ye);if(xt===null){Ie===null&&(Ie=ut);break}i&&Ie&&xt.alternate===null&&l(P,Ie),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt,Ie=ut}if(it===Z.length)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;itit?(ut=Ie,Ie=null):ut=Ie.sibling;var Ss=ie(P,Ie,xt.value,ye);if(Ss===null){Ie===null&&(Ie=ut);break}i&&Ie&&Ss.alternate===null&&l(P,Ie),H=y(Ss,H,it),bt===null?Fe=Ss:bt.sibling=Ss,bt=Ss,Ie=ut}if(xt.done)return o(P,Ie),ht&&gr(P,it),Fe;if(Ie===null){for(;!xt.done;it++,xt=Z.next())xt=xe(P,xt.value,ye),xt!==null&&(H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return ht&&gr(P,it),Fe}for(Ie=d(Ie);!xt.done;it++,xt=Z.next())xt=le(Ie,P,it,xt.value,ye),xt!==null&&(i&&xt.alternate!==null&&Ie.delete(xt.key===null?it:xt.key),H=y(xt,H,it),bt===null?Fe=xt:bt.sibling=xt,bt=xt);return i&&Ie.forEach(function(uD){return l(P,uD)}),ht&&gr(P,it),Fe}function Et(P,H,Z,ye){if(typeof Z=="object"&&Z!==null&&Z.type===C&&Z.key===null&&(Z=Z.props.children),typeof Z=="object"&&Z!==null){switch(Z.$$typeof){case w:e:{for(var Fe=Z.key;H!==null;){if(H.key===Fe){if(Fe=Z.type,Fe===C){if(H.tag===7){o(P,H.sibling),ye=m(H,Z.props.children),ye.return=P,P=ye;break e}}else if(H.elementType===Fe||typeof Fe=="object"&&Fe!==null&&Fe.$$typeof===G&&Ks(Fe)===H.type){o(P,H.sibling),ye=m(H,Z.props),lo(ye,Z),ye.return=P,P=ye;break e}o(P,H);break}else l(P,H);H=H.sibling}Z.type===C?(ye=Us(Z.props.children,P.mode,ye,Z.key),ye.return=P,P=ye):(ye=yu(Z.type,Z.key,Z.props,null,P.mode,ye),lo(ye,Z),ye.return=P,P=ye)}return S(P);case A:e:{for(Fe=Z.key;H!==null;){if(H.key===Fe)if(H.tag===4&&H.stateNode.containerInfo===Z.containerInfo&&H.stateNode.implementation===Z.implementation){o(P,H.sibling),ye=m(H,Z.children||[]),ye.return=P,P=ye;break e}else{o(P,H);break}else l(P,H);H=H.sibling}ye=Ip(Z,P.mode,ye),ye.return=P,P=ye}return S(P);case G:return Z=Ks(Z),Et(P,H,Z,ye)}if(ge(Z))return _e(P,H,Z,ye);if(ee(Z)){if(Fe=ee(Z),typeof Fe!="function")throw Error(r(150));return Z=Fe.call(Z),Ye(P,H,Z,ye)}if(typeof Z.then=="function")return Et(P,H,ku(Z),ye);if(Z.$$typeof===j)return Et(P,H,vu(P,Z),ye);Cu(P,Z)}return typeof Z=="string"&&Z!==""||typeof Z=="number"||typeof Z=="bigint"?(Z=""+Z,H!==null&&H.tag===6?(o(P,H.sibling),ye=m(H,Z),ye.return=P,P=ye):(o(P,H),ye=$p(Z,P.mode,ye),ye.return=P,P=ye),S(P)):o(P,H)}return function(P,H,Z,ye){try{so=0;var Fe=Et(P,H,Z,ye);return Vl=null,Fe}catch(Ie){if(Ie===Ul||Ie===Su)throw Ie;var bt=li(29,Ie,null,P.mode);return bt.lanes=ye,bt.return=P,bt}}}var Xs=zw(!0),Uw=zw(!1),ss=!1;function Qp(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Wp(i,l){i=i.updateQueue,l.updateQueue===i&&(l.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function ls(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function as(i,l,o){var d=i.updateQueue;if(d===null)return null;if(d=d.shared,(wt&2)!==0){var m=d.pending;return m===null?l.next=l:(l.next=m.next,m.next=l),d.pending=l,l=gu(i),Cw(i,null,o),l}return mu(i,d,l,o),gu(i)}function ao(i,l,o){if(l=l.updateQueue,l!==null&&(l=l.shared,(o&4194048)!==0)){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}function Zp(i,l){var o=i.updateQueue,d=i.alternate;if(d!==null&&(d=d.updateQueue,o===d)){var m=null,y=null;if(o=o.firstBaseUpdate,o!==null){do{var S={lane:o.lane,tag:o.tag,payload:o.payload,callback:null,next:null};y===null?m=y=S:y=y.next=S,o=o.next}while(o!==null);y===null?m=y=l:y=y.next=l}else m=y=l;o={baseState:d.baseState,firstBaseUpdate:m,lastBaseUpdate:y,shared:d.shared,callbacks:d.callbacks},i.updateQueue=o;return}i=o.lastBaseUpdate,i===null?o.firstBaseUpdate=l:i.next=l,o.lastBaseUpdate=l}var em=!1;function oo(){if(em){var i=zl;if(i!==null)throw i}}function co(i,l,o,d){em=!1;var m=i.updateQueue;ss=!1;var y=m.firstBaseUpdate,S=m.lastBaseUpdate,N=m.shared.pending;if(N!==null){m.shared.pending=null;var $=N,te=$.next;$.next=null,S===null?y=te:S.next=te,S=$;var fe=i.alternate;fe!==null&&(fe=fe.updateQueue,N=fe.lastBaseUpdate,N!==S&&(N===null?fe.firstBaseUpdate=te:N.next=te,fe.lastBaseUpdate=$))}if(y!==null){var xe=m.baseState;S=0,fe=te=$=null,N=y;do{var ie=N.lane&-536870913,le=ie!==N.lane;if(le?(ct&ie)===ie:(d&ie)===ie){ie!==0&&ie===Hl&&(em=!0),fe!==null&&(fe=fe.next={lane:0,tag:N.tag,payload:N.payload,callback:null,next:null});e:{var _e=i,Ye=N;ie=l;var Et=o;switch(Ye.tag){case 1:if(_e=Ye.payload,typeof _e=="function"){xe=_e.call(Et,xe,ie);break e}xe=_e;break e;case 3:_e.flags=_e.flags&-65537|128;case 0:if(_e=Ye.payload,ie=typeof _e=="function"?_e.call(Et,xe,ie):_e,ie==null)break e;xe=b({},xe,ie);break e;case 2:ss=!0}}ie=N.callback,ie!==null&&(i.flags|=64,le&&(i.flags|=8192),le=m.callbacks,le===null?m.callbacks=[ie]:le.push(ie))}else le={lane:ie,tag:N.tag,payload:N.payload,callback:N.callback,next:null},fe===null?(te=fe=le,$=xe):fe=fe.next=le,S|=ie;if(N=N.next,N===null){if(N=m.shared.pending,N===null)break;le=N,N=le.next,le.next=null,m.lastBaseUpdate=le,m.shared.pending=null}}while(!0);fe===null&&($=xe),m.baseState=$,m.firstBaseUpdate=te,m.lastBaseUpdate=fe,y===null&&(m.shared.lanes=0),fs|=S,i.lanes=S,i.memoizedState=xe}}function Vw(i,l){if(typeof i!="function")throw Error(r(191,i));i.call(l)}function Fw(i,l){var o=i.callbacks;if(o!==null)for(i.callbacks=null,i=0;iy?y:8;var S=q.T,N={};q.T=N,xm(i,!1,l,o);try{var $=m(),te=q.S;if(te!==null&&te(N,$),$!==null&&typeof $=="object"&&typeof $.then=="function"){var fe=ZR($,d);ho(i,l,fe,di(i))}else ho(i,l,d,di(i))}catch(xe){ho(i,l,{then:function(){},status:"rejected",reason:xe},di())}finally{J.p=y,S!==null&&N.types!==null&&(S.types=N.types),q.T=S}}function s4(){}function ym(i,l,o,d){if(i.tag!==5)throw Error(r(476));var m=SS(i).queue;wS(i,m,l,oe,o===null?s4:function(){return AS(i),o(d)})}function SS(i){var l=i.memoizedState;if(l!==null)return l;l={memoizedState:oe,baseState:oe,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:oe},next:null};var o={};return l.next={memoizedState:o,baseState:o,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vr,lastRenderedState:o},next:null},i.memoizedState=l,i=i.alternate,i!==null&&(i.memoizedState=l),l}function AS(i){var l=SS(i);l.next===null&&(l=i.alternate.memoizedState),ho(i,l.next.queue,{},di())}function bm(){return yn(Oo)}function kS(){return Gt().memoizedState}function CS(){return Gt().memoizedState}function l4(i){for(var l=i.return;l!==null;){switch(l.tag){case 24:case 3:var o=di();i=ls(o);var d=as(l,i,o);d!==null&&(Qn(d,l,o),ao(d,l,o)),l={cache:Kp()},i.payload=l;return}l=l.return}}function a4(i,l,o){var d=di();o={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null},Lu(i)?TS(l,o):(o=qp(i,l,o,d),o!==null&&(Qn(o,i,d),jS(o,l,d)))}function NS(i,l,o){var d=di();ho(i,l,o,d)}function ho(i,l,o,d){var m={lane:d,revertLane:0,gesture:null,action:o,hasEagerState:!1,eagerState:null,next:null};if(Lu(i))TS(l,m);else{var y=i.alternate;if(i.lanes===0&&(y===null||y.lanes===0)&&(y=l.lastRenderedReducer,y!==null))try{var S=l.lastRenderedState,N=y(S,o);if(m.hasEagerState=!0,m.eagerState=N,si(N,S))return mu(i,l,m,0),Mt===null&&pu(),!1}catch{}if(o=qp(i,l,m,d),o!==null)return Qn(o,i,d),jS(o,l,d),!0}return!1}function xm(i,l,o,d){if(d={lane:2,revertLane:Qm(),gesture:null,action:d,hasEagerState:!1,eagerState:null,next:null},Lu(i)){if(l)throw Error(r(479))}else l=qp(i,o,d,2),l!==null&&Qn(l,i,2)}function Lu(i){var l=i.alternate;return i===nt||l!==null&&l===nt}function TS(i,l){Pl=ju=!0;var o=i.pending;o===null?l.next=l:(l.next=o.next,o.next=l),i.pending=l}function jS(i,l,o){if((o&4194048)!==0){var d=l.lanes;d&=i.pendingLanes,o|=d,l.lanes=o,Bs(i,o)}}var po={readContext:yn,use:Mu,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};po.useEffectEvent=zt;var ES={readContext:yn,use:Mu,useCallback:function(i,l){return $n().memoizedState=[i,l===void 0?null:l],i},useContext:yn,useEffect:fS,useImperativeHandle:function(i,l,o){o=o!=null?o.concat([i]):null,Du(4194308,4,gS.bind(null,l,i),o)},useLayoutEffect:function(i,l){return Du(4194308,4,i,l)},useInsertionEffect:function(i,l){Du(4,2,i,l)},useMemo:function(i,l){var o=$n();l=l===void 0?null:l;var d=i();if(Js){V(!0);try{i()}finally{V(!1)}}return o.memoizedState=[d,l],d},useReducer:function(i,l,o){var d=$n();if(o!==void 0){var m=o(l);if(Js){V(!0);try{o(l)}finally{V(!1)}}}else m=l;return d.memoizedState=d.baseState=m,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:m},d.queue=i,i=i.dispatch=a4.bind(null,nt,i),[d.memoizedState,i]},useRef:function(i){var l=$n();return i={current:i},l.memoizedState=i},useState:function(i){i=fm(i);var l=i.queue,o=NS.bind(null,nt,l);return l.dispatch=o,[i.memoizedState,o]},useDebugValue:mm,useDeferredValue:function(i,l){var o=$n();return gm(o,i,l)},useTransition:function(){var i=fm(!1);return i=wS.bind(null,nt,i.queue,!0,!1),$n().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,l,o){var d=nt,m=$n();if(ht){if(o===void 0)throw Error(r(407));o=o()}else{if(o=l(),Mt===null)throw Error(r(349));(ct&127)!==0||Jw(d,l,o)}m.memoizedState=o;var y={value:o,getSnapshot:l};return m.queue=y,fS(Ww.bind(null,d,y,i),[i]),d.flags|=2048,Kl(9,{destroy:void 0},Qw.bind(null,d,y,o,l),null),o},useId:function(){var i=$n(),l=Mt.identifierPrefix;if(ht){var o=Zi,d=Wi;o=(d&~(1<<32-W(d)-1)).toString(32)+o,l="_"+l+"R_"+o,o=Eu++,0<\/script>",y=y.removeChild(y.firstChild);break;case"select":y=typeof d.is=="string"?S.createElement("select",{is:d.is}):S.createElement("select"),d.multiple?y.multiple=!0:d.size&&(y.size=d.size);break;default:y=typeof d.is=="string"?S.createElement(m,{is:d.is}):S.createElement(m)}}y[_t]=l,y[Yt]=d;e:for(S=l.child;S!==null;){if(S.tag===5||S.tag===6)y.appendChild(S.stateNode);else if(S.tag!==4&&S.tag!==27&&S.child!==null){S.child.return=S,S=S.child;continue}if(S===l)break e;for(;S.sibling===null;){if(S.return===null||S.return===l)break e;S=S.return}S.sibling.return=S.return,S=S.sibling}l.stateNode=y;e:switch(xn(y,m,d),m){case"button":case"input":case"select":case"textarea":d=!!d.autoFocus;break e;case"img":d=!0;break e;default:d=!1}d&&Sr(l)}}return qt(l),Dm(l,l.type,i===null?null:i.memoizedProps,l.pendingProps,o),null;case 6:if(i&&l.stateNode!=null)i.memoizedProps!==d&&Sr(l);else{if(typeof d!="string"&&l.stateNode===null)throw Error(r(166));if(i=Re.current,$l(l)){if(i=l.stateNode,o=l.memoizedProps,d=null,m=gn,m!==null)switch(m.tag){case 27:case 5:d=m.memoizedProps}i[_t]=l,i=!!(i.nodeValue===o||d!==null&&d.suppressHydrationWarning===!0||G2(i.nodeValue,o)),i||is(l,!0)}else i=td(i).createTextNode(d),i[_t]=l,l.stateNode=i}return qt(l),null;case 31:if(o=l.memoizedState,i===null||i.memoizedState!==null){if(d=$l(l),o!==null){if(i===null){if(!d)throw Error(r(318));if(i=l.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),i=!1}else o=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=o),i=!0;if(!i)return l.flags&256?(oi(l),l):(oi(l),null);if((l.flags&128)!==0)throw Error(r(558))}return qt(l),null;case 13:if(d=l.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(m=$l(l),d!==null&&d.dehydrated!==null){if(i===null){if(!m)throw Error(r(318));if(m=l.memoizedState,m=m!==null?m.dehydrated:null,!m)throw Error(r(317));m[_t]=l}else Vs(),(l.flags&128)===0&&(l.memoizedState=null),l.flags|=4;qt(l),m=!1}else m=Vp(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=m),m=!0;if(!m)return l.flags&256?(oi(l),l):(oi(l),null)}return oi(l),(l.flags&128)!==0?(l.lanes=o,l):(o=d!==null,i=i!==null&&i.memoizedState!==null,o&&(d=l.child,m=null,d.alternate!==null&&d.alternate.memoizedState!==null&&d.alternate.memoizedState.cachePool!==null&&(m=d.alternate.memoizedState.cachePool.pool),y=null,d.memoizedState!==null&&d.memoizedState.cachePool!==null&&(y=d.memoizedState.cachePool.pool),y!==m&&(d.flags|=2048)),o!==i&&o&&(l.child.flags|=8192),Hu(l,l.updateQueue),qt(l),null);case 4:return Je(),i===null&&tg(l.stateNode.containerInfo),qt(l),null;case 10:return br(l.type),qt(l),null;case 19:if(z(Kt),d=l.memoizedState,d===null)return qt(l),null;if(m=(l.flags&128)!==0,y=d.rendering,y===null)if(m)go(d,!1);else{if(Ut!==0||i!==null&&(i.flags&128)!==0)for(i=l.child;i!==null;){if(y=Tu(i),y!==null){for(l.flags|=128,go(d,!1),i=y.updateQueue,l.updateQueue=i,Hu(l,i),l.subtreeFlags=0,i=o,o=l.child;o!==null;)Nw(o,i),o=o.sibling;return me(Kt,Kt.current&1|2),ht&&gr(l,d.treeForkCount),l.child}i=i.sibling}d.tail!==null&&ft()>Pu&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304)}else{if(!m)if(i=Tu(y),i!==null){if(l.flags|=128,m=!0,i=i.updateQueue,l.updateQueue=i,Hu(l,i),go(d,!0),d.tail===null&&d.tailMode==="hidden"&&!y.alternate&&!ht)return qt(l),null}else 2*ft()-d.renderingStartTime>Pu&&o!==536870912&&(l.flags|=128,m=!0,go(d,!1),l.lanes=4194304);d.isBackwards?(y.sibling=l.child,l.child=y):(i=d.last,i!==null?i.sibling=y:l.child=y,d.last=y)}return d.tail!==null?(i=d.tail,d.rendering=i,d.tail=i.sibling,d.renderingStartTime=ft(),i.sibling=null,o=Kt.current,me(Kt,m?o&1|2:o&1),ht&&gr(l,d.treeForkCount),i):(qt(l),null);case 22:case 23:return oi(l),nm(),d=l.memoizedState!==null,i!==null?i.memoizedState!==null!==d&&(l.flags|=8192):d&&(l.flags|=8192),d?(o&536870912)!==0&&(l.flags&128)===0&&(qt(l),l.subtreeFlags&6&&(l.flags|=8192)):qt(l),o=l.updateQueue,o!==null&&Hu(l,o.retryQueue),o=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(o=i.memoizedState.cachePool.pool),d=null,l.memoizedState!==null&&l.memoizedState.cachePool!==null&&(d=l.memoizedState.cachePool.pool),d!==o&&(l.flags|=2048),i!==null&&z(Ys),null;case 24:return o=null,i!==null&&(o=i.memoizedState.cache),l.memoizedState.cache!==o&&(l.flags|=2048),br(Qt),qt(l),null;case 25:return null;case 30:return null}throw Error(r(156,l.tag))}function f4(i,l){switch(zp(l),l.tag){case 1:return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 3:return br(Qt),Je(),i=l.flags,(i&65536)!==0&&(i&128)===0?(l.flags=i&-65537|128,l):null;case 26:case 27:case 5:return dt(l),null;case 31:if(l.memoizedState!==null){if(oi(l),l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 13:if(oi(l),i=l.memoizedState,i!==null&&i.dehydrated!==null){if(l.alternate===null)throw Error(r(340));Vs()}return i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 19:return z(Kt),null;case 4:return Je(),null;case 10:return br(l.type),null;case 22:case 23:return oi(l),nm(),i!==null&&z(Ys),i=l.flags,i&65536?(l.flags=i&-65537|128,l):null;case 24:return br(Qt),null;case 25:return null;default:return null}}function ZS(i,l){switch(zp(l),l.tag){case 3:br(Qt),Je();break;case 26:case 27:case 5:dt(l);break;case 4:Je();break;case 31:l.memoizedState!==null&&oi(l);break;case 13:oi(l);break;case 19:z(Kt);break;case 10:br(l.type);break;case 22:case 23:oi(l),nm(),i!==null&&z(Ys);break;case 24:br(Qt)}}function yo(i,l){try{var o=l.updateQueue,d=o!==null?o.lastEffect:null;if(d!==null){var m=d.next;o=m;do{if((o.tag&i)===i){d=void 0;var y=o.create,S=o.inst;d=y(),S.destroy=d}o=o.next}while(o!==m)}}catch(N){Nt(l,l.return,N)}}function us(i,l,o){try{var d=l.updateQueue,m=d!==null?d.lastEffect:null;if(m!==null){var y=m.next;d=y;do{if((d.tag&i)===i){var S=d.inst,N=S.destroy;if(N!==void 0){S.destroy=void 0,m=l;var $=o,te=N;try{te()}catch(fe){Nt(m,$,fe)}}}d=d.next}while(d!==y)}}catch(fe){Nt(l,l.return,fe)}}function e2(i){var l=i.updateQueue;if(l!==null){var o=i.stateNode;try{Fw(l,o)}catch(d){Nt(i,i.return,d)}}}function t2(i,l,o){o.props=Qs(i.type,i.memoizedProps),o.state=i.memoizedState;try{o.componentWillUnmount()}catch(d){Nt(i,l,d)}}function bo(i,l){try{var o=i.ref;if(o!==null){switch(i.tag){case 26:case 27:case 5:var d=i.stateNode;break;case 30:d=i.stateNode;break;default:d=i.stateNode}typeof o=="function"?i.refCleanup=o(d):o.current=d}}catch(m){Nt(i,l,m)}}function er(i,l){var o=i.ref,d=i.refCleanup;if(o!==null)if(typeof d=="function")try{d()}catch(m){Nt(i,l,m)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof o=="function")try{o(null)}catch(m){Nt(i,l,m)}else o.current=null}function n2(i){var l=i.type,o=i.memoizedProps,d=i.stateNode;try{e:switch(l){case"button":case"input":case"select":case"textarea":o.autoFocus&&d.focus();break e;case"img":o.src?d.src=o.src:o.srcSet&&(d.srcset=o.srcSet)}}catch(m){Nt(i,i.return,m)}}function _m(i,l,o){try{var d=i.stateNode;_4(d,i.type,o,l),d[Yt]=l}catch(m){Nt(i,i.return,m)}}function i2(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&ys(i.type)||i.tag===4}function Lm(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i2(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&ys(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function qm(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?(o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o).insertBefore(i,l):(l=o.nodeType===9?o.body:o.nodeName==="HTML"?o.ownerDocument.body:o,l.appendChild(i),o=o._reactRootContainer,o!=null||l.onclick!==null||(l.onclick=hr));else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode,l=null),i=i.child,i!==null))for(qm(i,l,o),i=i.sibling;i!==null;)qm(i,l,o),i=i.sibling}function zu(i,l,o){var d=i.tag;if(d===5||d===6)i=i.stateNode,l?o.insertBefore(i,l):o.appendChild(i);else if(d!==4&&(d===27&&ys(i.type)&&(o=i.stateNode),i=i.child,i!==null))for(zu(i,l,o),i=i.sibling;i!==null;)zu(i,l,o),i=i.sibling}function r2(i){var l=i.stateNode,o=i.memoizedProps;try{for(var d=i.type,m=l.attributes;m.length;)l.removeAttributeNode(m[0]);xn(l,d,o),l[_t]=i,l[Yt]=o}catch(y){Nt(i,i.return,y)}}var Ar=!1,en=!1,Bm=!1,s2=typeof WeakSet=="function"?WeakSet:Set,on=null;function h4(i,l){if(i=i.containerInfo,rg=od,i=yw(i),Op(i)){if("selectionStart"in i)var o={start:i.selectionStart,end:i.selectionEnd};else e:{o=(o=i.ownerDocument)&&o.defaultView||window;var d=o.getSelection&&o.getSelection();if(d&&d.rangeCount!==0){o=d.anchorNode;var m=d.anchorOffset,y=d.focusNode;d=d.focusOffset;try{o.nodeType,y.nodeType}catch{o=null;break e}var S=0,N=-1,$=-1,te=0,fe=0,xe=i,ie=null;t:for(;;){for(var le;xe!==o||m!==0&&xe.nodeType!==3||(N=S+m),xe!==y||d!==0&&xe.nodeType!==3||($=S+d),xe.nodeType===3&&(S+=xe.nodeValue.length),(le=xe.firstChild)!==null;)ie=xe,xe=le;for(;;){if(xe===i)break t;if(ie===o&&++te===m&&(N=S),ie===y&&++fe===d&&($=S),(le=xe.nextSibling)!==null)break;xe=ie,ie=xe.parentNode}xe=le}o=N===-1||$===-1?null:{start:N,end:$}}else o=null}o=o||{start:0,end:0}}else o=null;for(sg={focusedElem:i,selectionRange:o},od=!1,on=l;on!==null;)if(l=on,i=l.child,(l.subtreeFlags&1028)!==0&&i!==null)i.return=l,on=i;else for(;on!==null;){switch(l=on,y=l.alternate,i=l.flags,l.tag){case 0:if((i&4)!==0&&(i=l.updateQueue,i=i!==null?i.events:null,i!==null))for(o=0;o title"))),xn(y,d,o),y[_t]=i,Xt(y),d=y;break e;case"link":var S=dA("link","href",m).get(d+(o.href||""));if(S){for(var N=0;NEt&&(S=Et,Et=Ye,Ye=S);var P=mw(N,Ye),H=mw(N,Et);if(P&&H&&(le.rangeCount!==1||le.anchorNode!==P.node||le.anchorOffset!==P.offset||le.focusNode!==H.node||le.focusOffset!==H.offset)){var Z=xe.createRange();Z.setStart(P.node,P.offset),le.removeAllRanges(),Ye>Et?(le.addRange(Z),le.extend(H.node,H.offset)):(Z.setEnd(H.node,H.offset),le.addRange(Z))}}}}for(xe=[],le=N;le=le.parentNode;)le.nodeType===1&&xe.push({element:le,left:le.scrollLeft,top:le.scrollTop});for(typeof N.focus=="function"&&N.focus(),N=0;No?32:o,q.T=null,o=Fm,Fm=null;var y=ps,S=jr;if(sn=0,Wl=ps=null,jr=0,(wt&6)!==0)throw Error(r(331));var N=wt;if(wt|=4,g2(y.current),h2(y,y.current,S,o),wt=N,ko(0,!1),k&&typeof k.onPostCommitFiberRoot=="function")try{k.onPostCommitFiberRoot(X,y)}catch{}return!0}finally{J.p=m,q.T=d,_2(i,l)}}function q2(i,l,o){l=Si(o,l),l=Am(i.stateNode,l,2),i=as(i,l,2),i!==null&&(jn(i,2),tr(i))}function Nt(i,l,o){if(i.tag===3)q2(i,i,o);else for(;l!==null;){if(l.tag===3){q2(l,i,o);break}else if(l.tag===1){var d=l.stateNode;if(typeof l.type.getDerivedStateFromError=="function"||typeof d.componentDidCatch=="function"&&(hs===null||!hs.has(d))){i=Si(o,i),o=BS(2),d=as(l,o,2),d!==null&&($S(o,d,l,i),jn(d,2),tr(d));break}}l=l.return}}function Gm(i,l,o){var d=i.pingCache;if(d===null){d=i.pingCache=new g4;var m=new Set;d.set(l,m)}else m=d.get(l),m===void 0&&(m=new Set,d.set(l,m));m.has(o)||(Hm=!0,m.add(o),i=w4.bind(null,i,l,o),l.then(i,i))}function w4(i,l,o){var d=i.pingCache;d!==null&&d.delete(l),i.pingedLanes|=i.suspendedLanes&o,i.warmLanes&=~o,Mt===i&&(ct&o)===o&&(Ut===4||Ut===3&&(ct&62914560)===ct&&300>ft()-Fu?(wt&2)===0&&Zl(i,0):zm|=o,Ql===ct&&(Ql=0)),tr(i)}function B2(i,l){l===0&&(l=Dt()),i=zs(i,l),i!==null&&(jn(i,l),tr(i))}function S4(i){var l=i.memoizedState,o=0;l!==null&&(o=l.retryLane),B2(i,o)}function A4(i,l){var o=0;switch(i.tag){case 31:case 13:var d=i.stateNode,m=i.memoizedState;m!==null&&(o=m.retryLane);break;case 19:d=i.stateNode;break;case 22:d=i.stateNode._retryCache;break;default:throw Error(r(314))}d!==null&&d.delete(l),B2(i,o)}function k4(i,l){return We(i,l)}var Qu=null,ta=null,Xm=!1,Wu=!1,Jm=!1,gs=0;function tr(i){i!==ta&&i.next===null&&(ta===null?Qu=ta=i:ta=ta.next=i),Wu=!0,Xm||(Xm=!0,N4())}function ko(i,l){if(!Jm&&Wu){Jm=!0;do for(var o=!1,d=Qu;d!==null;){if(i!==0){var m=d.pendingLanes;if(m===0)var y=0;else{var S=d.suspendedLanes,N=d.pingedLanes;y=(1<<31-W(42|i)+1)-1,y&=m&~(S&~N),y=y&201326741?y&201326741|1:y?y|2:0}y!==0&&(o=!0,z2(d,y))}else y=ct,y=Le(d,d===Mt?y:0,d.cancelPendingCommit!==null||d.timeoutHandle!==-1),(y&3)===0||ze(d,y)||(o=!0,z2(d,y));d=d.next}while(o);Jm=!1}}function C4(){$2()}function $2(){Wu=Xm=!1;var i=0;gs!==0&&q4()&&(i=gs);for(var l=ft(),o=null,d=Qu;d!==null;){var m=d.next,y=I2(d,l);y===0?(d.next=null,o===null?Qu=m:o.next=m,m===null&&(ta=o)):(o=d,(i!==0||(y&3)!==0)&&(Wu=!0)),d=m}sn!==0&&sn!==5||ko(i),gs!==0&&(gs=0)}function I2(i,l){for(var o=i.suspendedLanes,d=i.pingedLanes,m=i.expirationTimes,y=i.pendingLanes&-62914561;0N)break;var fe=$.transferSize,xe=$.initiatorType;fe&&X2(xe)&&($=$.responseEnd,S+=fe*($"u"?null:document;function aA(i,l,o){var d=na;if(d&&typeof l=="string"&&l){var m=vi(l);m='link[rel="'+i+'"][href="'+m+'"]',typeof o=="string"&&(m+='[crossorigin="'+o+'"]'),lA.has(m)||(lA.add(m),i={rel:i,crossOrigin:o,href:l},d.querySelector(m)===null&&(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function P4(i){Er.D(i),aA("dns-prefetch",i,null)}function Y4(i,l){Er.C(i,l),aA("preconnect",i,l)}function K4(i,l,o){Er.L(i,l,o);var d=na;if(d&&i&&l){var m='link[rel="preload"][as="'+vi(l)+'"]';l==="image"&&o&&o.imageSrcSet?(m+='[imagesrcset="'+vi(o.imageSrcSet)+'"]',typeof o.imageSizes=="string"&&(m+='[imagesizes="'+vi(o.imageSizes)+'"]')):m+='[href="'+vi(i)+'"]';var y=m;switch(l){case"style":y=ia(i);break;case"script":y=ra(i)}ji.has(y)||(i=b({rel:"preload",href:l==="image"&&o&&o.imageSrcSet?void 0:i,as:l},o),ji.set(y,i),d.querySelector(m)!==null||l==="style"&&d.querySelector(jo(y))||l==="script"&&d.querySelector(Eo(y))||(l=d.createElement("link"),xn(l,"link",i),Xt(l),d.head.appendChild(l)))}}function G4(i,l){Er.m(i,l);var o=na;if(o&&i){var d=l&&typeof l.as=="string"?l.as:"script",m='link[rel="modulepreload"][as="'+vi(d)+'"][href="'+vi(i)+'"]',y=m;switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":y=ra(i)}if(!ji.has(y)&&(i=b({rel:"modulepreload",href:i},l),ji.set(y,i),o.querySelector(m)===null)){switch(d){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(o.querySelector(Eo(y)))return}d=o.createElement("link"),xn(d,"link",i),Xt(d),o.head.appendChild(d)}}}function X4(i,l,o){Er.S(i,l,o);var d=na;if(d&&i){var m=fr(d).hoistableStyles,y=ia(i);l=l||"default";var S=m.get(y);if(!S){var N={loading:0,preload:null};if(S=d.querySelector(jo(y)))N.loading=5;else{i=b({rel:"stylesheet",href:i,"data-precedence":l},o),(o=ji.get(y))&&fg(i,o);var $=S=d.createElement("link");Xt($),xn($,"link",i),$._p=new Promise(function(te,fe){$.onload=te,$.onerror=fe}),$.addEventListener("load",function(){N.loading|=1}),$.addEventListener("error",function(){N.loading|=2}),N.loading|=4,id(S,l,d)}S={type:"stylesheet",instance:S,count:1,state:N},m.set(y,S)}}}function J4(i,l){Er.X(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function Q4(i,l){Er.M(i,l);var o=na;if(o&&i){var d=fr(o).hoistableScripts,m=ra(i),y=d.get(m);y||(y=o.querySelector(Eo(m)),y||(i=b({src:i,async:!0,type:"module"},l),(l=ji.get(m))&&hg(i,l),y=o.createElement("script"),Xt(y),xn(y,"link",i),o.head.appendChild(y)),y={type:"script",instance:y,count:1,state:null},d.set(m,y))}}function oA(i,l,o,d){var m=(m=Re.current)?nd(m):null;if(!m)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof o.precedence=="string"&&typeof o.href=="string"?(l=ia(o.href),o=fr(m).hoistableStyles,d=o.get(l),d||(d={type:"style",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};case"link":if(o.rel==="stylesheet"&&typeof o.href=="string"&&typeof o.precedence=="string"){i=ia(o.href);var y=fr(m).hoistableStyles,S=y.get(i);if(S||(m=m.ownerDocument||m,S={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},y.set(i,S),(y=m.querySelector(jo(i)))&&!y._p&&(S.instance=y,S.state.loading=5),ji.has(i)||(o={rel:"preload",as:"style",href:o.href,crossOrigin:o.crossOrigin,integrity:o.integrity,media:o.media,hrefLang:o.hrefLang,referrerPolicy:o.referrerPolicy},ji.set(i,o),y||W4(m,i,o,S.state))),l&&d===null)throw Error(r(528,""));return S}if(l&&d!==null)throw Error(r(529,""));return null;case"script":return l=o.async,o=o.src,typeof o=="string"&&l&&typeof l!="function"&&typeof l!="symbol"?(l=ra(o),o=fr(m).hoistableScripts,d=o.get(l),d||(d={type:"script",instance:null,count:0,state:null},o.set(l,d)),d):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function ia(i){return'href="'+vi(i)+'"'}function jo(i){return'link[rel="stylesheet"]['+i+"]"}function cA(i){return b({},i,{"data-precedence":i.precedence,precedence:null})}function W4(i,l,o,d){i.querySelector('link[rel="preload"][as="style"]['+l+"]")?d.loading=1:(l=i.createElement("link"),d.preload=l,l.addEventListener("load",function(){return d.loading|=1}),l.addEventListener("error",function(){return d.loading|=2}),xn(l,"link",o),Xt(l),i.head.appendChild(l))}function ra(i){return'[src="'+vi(i)+'"]'}function Eo(i){return"script[async]"+i}function uA(i,l,o){if(l.count++,l.instance===null)switch(l.type){case"style":var d=i.querySelector('style[data-href~="'+vi(o.href)+'"]');if(d)return l.instance=d,Xt(d),d;var m=b({},o,{"data-href":o.href,"data-precedence":o.precedence,href:null,precedence:null});return d=(i.ownerDocument||i).createElement("style"),Xt(d),xn(d,"style",m),id(d,o.precedence,i),l.instance=d;case"stylesheet":m=ia(o.href);var y=i.querySelector(jo(m));if(y)return l.state.loading|=4,l.instance=y,Xt(y),y;d=cA(o),(m=ji.get(m))&&fg(d,m),y=(i.ownerDocument||i).createElement("link"),Xt(y);var S=y;return S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),l.state.loading|=4,id(y,o.precedence,i),l.instance=y;case"script":return y=ra(o.src),(m=i.querySelector(Eo(y)))?(l.instance=m,Xt(m),m):(d=o,(m=ji.get(y))&&(d=b({},o),hg(d,m)),i=i.ownerDocument||i,m=i.createElement("script"),Xt(m),xn(m,"link",d),i.head.appendChild(m),l.instance=m);case"void":return null;default:throw Error(r(443,l.type))}else l.type==="stylesheet"&&(l.state.loading&4)===0&&(d=l.instance,l.state.loading|=4,id(d,o.precedence,i));return l.instance}function id(i,l,o){for(var d=o.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),m=d.length?d[d.length-1]:null,y=m,S=0;S title"):null)}function Z4(i,l,o){if(o===1||l.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof l.precedence!="string"||typeof l.href!="string"||l.href==="")break;return!0;case"link":if(typeof l.rel!="string"||typeof l.href!="string"||l.href===""||l.onLoad||l.onError)break;return l.rel==="stylesheet"?(i=l.disabled,typeof l.precedence=="string"&&i==null):!0;case"script":if(l.async&&typeof l.async!="function"&&typeof l.async!="symbol"&&!l.onLoad&&!l.onError&&l.src&&typeof l.src=="string")return!0}return!1}function hA(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function eD(i,l,o,d){if(o.type==="stylesheet"&&(typeof d.media!="string"||matchMedia(d.media).matches!==!1)&&(o.state.loading&4)===0){if(o.instance===null){var m=ia(d.href),y=l.querySelector(jo(m));if(y){l=y._p,l!==null&&typeof l=="object"&&typeof l.then=="function"&&(i.count++,i=sd.bind(i),l.then(i,i)),o.state.loading|=4,o.instance=y,Xt(y);return}y=l.ownerDocument||l,d=cA(d),(m=ji.get(m))&&fg(d,m),y=y.createElement("link"),Xt(y);var S=y;S._p=new Promise(function(N,$){S.onload=N,S.onerror=$}),xn(y,"link",d),o.instance=y}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(o,l),(l=o.state.preload)&&(o.state.loading&3)===0&&(i.count++,o=sd.bind(i),l.addEventListener("load",o),l.addEventListener("error",o))}}var pg=0;function tD(i,l){return i.stylesheets&&i.count===0&&ad(i,i.stylesheets),0pg?50:800)+l);return i.unsuspend=o,function(){i.unsuspend=null,clearTimeout(d),clearTimeout(m)}}:null}function sd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ad(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var ld=null;function ad(i,l){i.stylesheets=null,i.unsuspend!==null&&(i.count++,ld=new Map,l.forEach(nD,i),ld=null,sd.call(i))}function nD(i,l){if(!(l.state.loading&4)){var o=ld.get(i);if(o)var d=o.get(null);else{o=new Map,ld.set(i,o);for(var m=i.querySelectorAll("link[data-precedence],style[data-precedence]"),y=0;y"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(t)}catch(e){console.error(e)}}return t(),gd.exports=qA(),gd.exports}var $A=BA(),I=vd();const Sd=Sg(I);const IA=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),HA=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(e,n,r)=>r?r.toUpperCase():n.toLowerCase()),Dg=t=>{const e=HA(t);return e.charAt(0).toUpperCase()+e.slice(1)},_g=(...t)=>t.filter((e,n,r)=>!!e&&e.trim()!==""&&r.indexOf(e)===n).join(" ").trim(),zA=t=>{for(const e in t)if(e.startsWith("aria-")||e==="role"||e==="title")return!0};var UA={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const VA=I.forwardRef(({color:t="currentColor",size:e=24,strokeWidth:n=2,absoluteStrokeWidth:r,className:s="",children:a,iconNode:c,...u},f)=>I.createElement("svg",{ref:f,...UA,width:e,height:e,stroke:t,strokeWidth:r?Number(n)*24/Number(e):n,className:_g("lucide",s),...!a&&!zA(u)&&{"aria-hidden":"true"},...u},[...c.map(([h,g])=>I.createElement(h,g)),...Array.isArray(a)?a:[a]]));const st=(t,e)=>{const n=I.forwardRef(({className:r,...s},a)=>I.createElement(VA,{ref:a,iconNode:e,className:_g(`lucide-${IA(Dg(t))}`,`lucide-${t}`,r),...s}));return n.displayName=Dg(t),n};const Lg=st("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const _o=st("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);const qg=st("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Bg=st("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const $g=st("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const Ad=st("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const oa=st("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const FA=st("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const kd=st("clock-3",[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const PA=st("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const Cd=st("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Nd=st("external-link",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]]);const Ig=st("file-text",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const YA=st("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const KA=st("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const GA=st("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const XA=st("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const JA=st("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const QA=st("lock-open",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]]);const WA=st("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const ZA=st("menu",[["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 18h16",key:"19g7jn"}],["path",{d:"M4 6h16",key:"1o0s65"}]]);const Td=st("panel-left-close",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);const jd=st("panel-left-open",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);const ca=st("play",[["polygon",{points:"6 3 20 12 6 21 6 3",key:"1oa8hb"}]]);const ks=st("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const ek=st("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const tk=st("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Hg=st("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const zg=st("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const nk=st("settings",[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const ik=st("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ug=st("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Vg=st("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const fi=st("trash-2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]]);const Ed=st("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const Fg=st("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rk=st("wand-sparkles",[["path",{d:"m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72",key:"ul74o6"}],["path",{d:"m14 7 3 3",key:"1r5n42"}],["path",{d:"M5 6v4",key:"ilb8ba"}],["path",{d:"M19 14v4",key:"blhpug"}],["path",{d:"M10 2v2",key:"7u0qdc"}],["path",{d:"M7 8H3",key:"zfb6yr"}],["path",{d:"M21 16h-4",key:"1cnmox"}],["path",{d:"M11 3H9",key:"1obp7u"}]]);const Od=st("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);function sk(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var wn={},Lo={},Or={},Pg;function ua(){if(Pg)return Or;Pg=1;function t(c){return typeof c>"u"||c===null}function e(c){return typeof c=="object"&&c!==null}function n(c){return Array.isArray(c)?c:t(c)?[]:[c]}function r(c,u){if(u){const f=Object.keys(u);for(let h=0,g=f.length;hb&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const O=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+O.str+` +`+n.mark.snippet),a+" "+s):a}function e(n,r){Error.call(this),this.name="YAMLException",this.reason=n,this.mark=r,this.message=t(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e.prototype.toString=function(r){return this.name+": "+t(this,r)},Md=e,Md}var Rd,Kg;function lk(){if(Kg)return Rd;Kg=1;const t=ua();function e(s,a,c,u,f){let h="",g="";const b=Math.floor(f/2)-1;return u-a>b&&(h=" ... ",a=u-b+h.length),c-u>b&&(g=" ...",c=u+b-g.length),{str:h+s.slice(a,c).replace(/\t/g,"→")+g,pos:u-a+h.length}}function n(s,a){return t.repeat(" ",a-s.length)+s}function r(s,a){if(a=Object.create(a||null),!s.buffer)return null;a.maxLength||(a.maxLength=79),typeof a.indent!="number"&&(a.indent=1),typeof a.linesBefore!="number"&&(a.linesBefore=3),typeof a.linesAfter!="number"&&(a.linesAfter=2);const c=/\r?\n|\r|\0/g,u=[0],f=[];let h,g=-1;for(;h=c.exec(s.buffer);)f.push(h.index),u.push(h.index+h[0].length),s.position<=h.index&&g<0&&(g=u.length-2);g<0&&(g=u.length-1);let b="";const v=Math.min(s.line+a.linesAfter,f.length).toString().length,w=a.maxLength-(a.indent+v+3);for(let C=1;C<=a.linesBefore&&!(g-C<0);C++){const E=e(s.buffer,u[g-C],f[g-C],s.position-(u[g]-u[g-C]),w);b=t.repeat(" ",a.indent)+n((s.line-C+1).toString(),v)+" | "+E.str+` `+b}const A=e(s.buffer,u[g],f[g],s.position,w);b+=t.repeat(" ",a.indent)+n((s.line+1).toString(),v)+" | "+A.str+` `,b+=t.repeat("-",a.indent+v+3+A.pos)+`^ -`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const O=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+O.str+` -`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],E=+(h[11]||0);f=(D*60+E)*6e4,h[9]==="-"&&(f=-f)}const O=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&O.setTime(O.getTime()-f),O}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= -\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const V=x|32;return V>=97&&V<=102?V-97+10:-1}function R(x){return x===120?2:x===117?4:x===85?8:0}function J(x){return x>=48&&x<=57?x-48:-1}function U(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` -`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,V,pe){V==="__proto__"?Object.defineProperty(x,V,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[V]=pe}const W=new Array(256),ye=new Array(256);for(let x=0;x<256;x++)W[x]=U(x)?1:0,ye[x]=U(x);function me(x,V){this.input=x,this.filename=V.filename||null,this.schema=V.schema||r,this.onWarning=V.onWarning||null,this.legacy=V.legacy||!1,this.json=V.json||!1,this.listener=V.listener||null,this.maxDepth=typeof V.maxDepth=="number"?V.maxDepth:100,this.maxTotalMergeKeys=typeof V.maxTotalMergeKeys=="number"?V.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function fe(x,V){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(V,pe)}function L(x,V){throw fe(x,V)}function Q(x,V){x.onWarning&&x.onWarning.call(null,fe(x,V))}function oe(x,V,pe){const ae=x.anchorMapTransactions;if(ae.length!==0){const X=ae[ae.length-1];s.call(X,V)||(X[V]={existed:s.call(x.anchorMap,V),value:x.anchorMap[V]})}x.anchorMap[V]=pe}function ue(x){x.anchorMapTransactions.push(Object.create(null))}function ve(x){const V=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ae=pe[pe.length-1],X=Object.keys(V);for(let k=0,F=X.length;k=0;ae-=1){const X=V[pe[ae]];X.existed?x.anchorMap[pe[ae]]=X.value:delete x.anchorMap[pe[ae]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function he(x,V){x.position=V.position,x.line=V.line,x.lineStart=V.lineStart,x.lineIndent=V.lineIndent,x.firstTabInLine=V.firstTabInLine,x.tag=V.tag,x.anchor=V.anchor,x.kind=V.kind,x.result=V.result}const ne={YAML:function(V,pe,ae){V.version!==null&&L(V,"duplication of %YAML directive"),ae.length!==1&&L(V,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ae[0]);X===null&&L(V,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),F=parseInt(X[2],10);k!==1&&L(V,"unacceptable YAML version of the document"),V.version=ae[0],V.checkLineBreaks=F<2,F!==1&&F!==2&&Q(V,"unsupported YAML version of the document")},TAG:function(V,pe,ae){let X;ae.length!==2&&L(V,"TAG directive accepts exactly two arguments");const k=ae[0];X=ae[1],C.test(k)||L(V,"ill-formed tag handle (first argument) of the TAG directive"),s.call(V.tagMap,k)&&L(V,'there is a previously declared suffix for "'+k+'" tag handle'),O.test(X)||L(V,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{L(V,"tag prefix is malformed: "+X)}V.tagMap[k]=X}};function ke(x,V,pe,ae){if(V=32&&Z<=1114111||L(x,"expected valid JSON character")}else v.test(X)&&L(x,"the stream contains non-printable characters");x.result+=X}}function _e(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&L(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function $e(x,V,pe,ae){t.isObject(pe)||L(x,"cannot merge mappings; the provided source object is unacceptable"),_e(x);const X=Object.keys(pe);for(let k=0,F=X.length;k100&&L(x,"abnormal merge sequence size");for(let P=0,ce=k.length;P1&&(x.result+=t.repeat(` -`,V-1))}function Ce(x,V,pe){let ae,X,k,F,Z,xe;const P=x.kind,ce=x.result;let le=x.input.charCodeAt(x.position);if(M(le)||_(le)||le===35||le===38||le===42||le===33||le===124||le===62||le===39||le===34||le===37||le===64||le===96)return!1;if(le===63||le===45){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))return!1}for(x.kind="scalar",x.result="",ae=X=x.position,k=!1;le!==0;){if(le===58){const we=x.input.charCodeAt(x.position+1);if(M(we)||pe&&_(we))break}else if(le===35){const we=x.input.charCodeAt(x.position-1);if(M(we))break}else{if(x.position===x.lineStart&&ut(x)||pe&&_(le))break;if(E(le))if(F=x.line,Z=x.lineStart,xe=x.lineIndent,Ie(x,!1,-1),x.lineIndent>=V){k=!0,le=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=F,x.lineStart=Z,x.lineIndent=xe;break}}k&&(ke(x,ae,X,!1),Rt(x,x.line-F),ae=X=x.position,k=!1),j(le)||(X=x.position+1),le=x.input.charCodeAt(++x.position)}return ke(x,ae,X,!1),x.result?!0:(x.kind=P,x.result=ce,!1)}function Ee(x,V){let pe,ae,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(ke(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ae=x.position;else return!0;else E(X)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ae=x.position));L(x,"unexpected end of the stream within a single quoted scalar")}function G(x,V){let pe,ae,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ae=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return ke(x,pe,x.position,!0),x.position++,!0;if(k===92){if(ke(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),E(k))Ie(x,!1,V);else if(k<256&&W[k])x.result+=ye[k],x.position++;else if((X=R(k))>0){let F=X,Z=0;for(;F>0;F--)k=x.input.charCodeAt(++x.position),(X=q(k))>=0?Z=(Z<<4)+X:L(x,"expected hexadecimal character");x.result+=B(Z),x.position++}else L(x,"unknown escape sequence");pe=ae=x.position}else E(k)?(ke(x,pe,ae,!0),Rt(x,Ie(x,!1,V)),pe=ae=x.position):x.position===x.lineStart&&ut(x)?L(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ae=x.position))}L(x,"unexpected end of the stream within a double quoted scalar")}function Se(x,V){let pe=!0,ae,X,k;const F=x.tag;let Z;const xe=x.anchor;let P,ce,le,we;const Oe=Object.create(null);let Te,Be,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)P=93,we=!1,Z=[];else if(Ve===123)P=125,we=!0,Z={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,Z),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===P)return x.position++,x.tag=F,x.anchor=xe,x.kind=we?"mapping":"sequence",x.result=Z,!0;if(pe?Ve===44&&L(x,"expected the node content, but found ','"):L(x,"missed comma between flow collection entries"),Be=Te=ze=null,ce=le=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);M(Dt)&&(ce=le=!0,x.position++,Ie(x,!0,V))}ae=x.line,X=x.lineStart,k=x.position,ht(x,V,a,!1,!0),Be=x.tag,Te=x.result,Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),(le||x.line===ae)&&Ve===58&&(ce=!0,Ve=x.input.charCodeAt(++x.position),Ie(x,!0,V),ht(x,V,a,!1,!0),ze=x.result),we?Pe(x,Z,Oe,Be,Te,ze,ae,X,k):ce?Z.push(Pe(x,null,Oe,Be,Te,ze,ae,X,k)):Z.push(Te),Ie(x,!0,V),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}L(x,"unexpected end of the stream within a flow collection")}function Ne(x,V){let pe,ae=h,X=!1,k=!1,F=V,Z=0,xe=!1,P,ce=x.input.charCodeAt(x.position);if(ce===124)pe=!1;else if(ce===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";ce!==0;)if(ce=x.input.charCodeAt(++x.position),ce===43||ce===45)h===ae?ae=ce===43?b:g:L(x,"repeat of a chomping mode identifier");else if((P=J(ce))>=0)P===0?L(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?L(x,"repeat of an indentation width identifier"):(F=V+P-1,k=!0);else break;if(j(ce)){do ce=x.input.charCodeAt(++x.position);while(j(ce));if(ce===35)do ce=x.input.charCodeAt(++x.position);while(!E(ce)&&ce!==0)}for(;ce!==0;){for(Ke(x),x.lineIndent=0,ce=x.input.charCodeAt(x.position);(!k||x.lineIndentF&&(F=x.lineIndent),E(ce)){Z++;continue}if(!k&&F===0&&L(x,"missing indentation for block scalar"),x.lineIndentV)&&F!==0)L(x,"bad indentation of a sequence entry");else if(x.lineIndentV)&&(Te&&(X=x.line,k=x.lineStart,F=x.position),ht(x,V,f,!0,ae)&&(Te?we=x.result:Oe=x.result),Te||(Pe(x,P,ce,le,we,Oe,X,k,F),le=we=Oe=null),Ie(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>V)&&ze!==0)L(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&L(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=F=f===pe||u===pe;if(ae&&Ie(x,!0,-1)&&(xe=!0,x.lineIndent>V?Z=1:x.lineIndent===V?Z=0:x.lineIndentV?Z=1:x.lineIndent===V?Z=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Be=0,ze=x.implicitTypes.length;Be"),x.result!==null&&le.kind!==x.kind&&L(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+le.kind+'", not "'+x.kind+'"'),le.resolve(x.result,x.tag)?(x.result=le.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):L(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||P}function ni(x){const V=x.position;let pe=!1,ae;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ae=x.input.charCodeAt(x.position))!==0&&(Ie(x,!0,-1),ae=x.input.charCodeAt(x.position),!(x.lineIndent>0||ae!==37));){pe=!0,ae=x.input.charCodeAt(++x.position);let X=x.position;for(;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),F=[];for(k.length<1&&L(x,"directive name must not be less than one character in length");ae!==0;){for(;j(ae);)ae=x.input.charCodeAt(++x.position);if(ae===35){do ae=x.input.charCodeAt(++x.position);while(ae!==0&&!E(ae));break}if(E(ae))break;for(X=x.position;ae!==0&&!M(ae);)ae=x.input.charCodeAt(++x.position);F.push(x.input.slice(X,x.position))}ae!==0&&Ke(x),s.call(ne,k)?ne[k](x,k,F):Q(x,'unknown document directive "'+k+'"')}if(Ie(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Ie(x,!0,-1)):pe&&L(x,"directives end mark is expected"),ht(x,x.lineIndent-1,f,!1,!0),Ie(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(V,x.position))&&Q(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&ut(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Ie(x,!0,-1));return}x.position"u"&&(pe=V,V=null);const ae=Vn(x,pe);if(typeof V!="function")return ae;for(let X=0,k=ae.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function $e(k){return _e(k)&&k!==a&&k!==f&&k!==u}function Pe(k,F,Z){const xe=$e(k),P=xe&&!ke(k);return(Z?xe:xe&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye)&&k!==v&&!(F===j&&!P)||$e(F)&&!ke(F)&&k===v||F===j&&P}function Ke(k){return _e(k)&&k!==a&&!ke(k)&&k!==E&&k!==q&&k!==j&&k!==D&&k!==J&&k!==U&&k!==K&&k!==ye&&k!==v&&k!==A&&k!==O&&k!==g&&k!==W&&k!==M&&k!==_&&k!==C&&k!==b&&k!==w&&k!==R&&k!==B}function Ie(k){return!ke(k)&&k!==j}function ut(k,F){const Z=k.charCodeAt(F);let xe;return Z>=55296&&Z<=56319&&F+1=56320&&xe<=57343)?(Z-55296)*1024+xe-56320+65536:Z}function Rt(k){return/^\n* /.test(k)}const Ce=1,Ee=2,G=3,Se=4,Ne=5;function Re(k,F,Z,xe,P,ce,le,we){let Oe,Te=0,Be=null,ze=!1,Ve=!1;const Dt=xe!==-1;let Fn=-1,jn=Ke(ut(k,0))&&Ie(ut(k,k.length-1));if(F||le)for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}else{for(Oe=0;Oe=65536?Oe+=2:Oe++){if(Te=ut(k,Oe),Te===u)ze=!0,Dt&&(Ve=Ve||Oe-Fn-1>xe&&k[Fn+1]!==" ",Fn=Oe);else if(!_e(Te))return Ne;jn=jn&&Pe(Te,Be,we),Be=Te}Ve=Ve||Dt&&Oe-Fn-1>xe&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!le&&!P(k)?Ce:ce===ve?Ne:Ee:Z>9&&Rt(k)?Ne:le?ce===ve?Ne:Ee:Ve?Se:G}function Ge(k,F,Z,xe,P){k.dump=(function(){if(F.length===0)return k.quotingType===ve?'""':"''";if(!k.noCompatMode&&(fe.indexOf(F)!==-1||L.test(F)))return k.quotingType===ve?'"'+F+'"':"'"+F+"'";const ce=k.indent*Math.max(1,Z),le=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-ce),we=xe||k.flowLevel>-1&&Z>=k.flowLevel;function Oe(Te){return ne(k,Te)}switch(Re(F,we,k.indent,le,Oe,k.quotingType,k.forceQuotes&&!xe,P)){case Ce:return F;case Ee:return"'"+F.replace(/'/g,"''")+"'";case G:return"|"+st(F,k.indent)+Et(z(F,ce));case Se:return">"+st(F,k.indent)+Et(z(ti(F,le),ce));case Ne:return'"'+ht(F)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function st(k,F){const Z=Rt(k)?String(F):"",xe=k[k.length-1]===` -`,ce=xe&&(k[k.length-2]===` +`;for(let C=1;C<=a.linesAfter&&!(g+C>=f.length);C++){const E=e(s.buffer,u[g+C],f[g+C],s.position-(u[g]-u[g+C]),w);b+=t.repeat(" ",a.indent)+n((s.line+C+1).toString(),v)+" | "+E.str+` +`}return b.replace(/\n$/,"")}return Rd=r,Rd}var Dd,Gg;function Mn(){if(Gg)return Dd;Gg=1;const t=da(),e=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],n=["scalar","sequence","mapping"];function r(a){const c={};return a!==null&&Object.keys(a).forEach(function(u){a[u].forEach(function(f){c[String(f)]=u})}),c}function s(a,c){if(c=c||{},Object.keys(c).forEach(function(u){if(e.indexOf(u)===-1)throw new t('Unknown option "'+u+'" is met in definition of "'+a+'" YAML type.')}),this.options=c,this.tag=a,this.kind=c.kind||null,this.resolve=c.resolve||function(){return!0},this.construct=c.construct||function(u){return u},this.instanceOf=c.instanceOf||null,this.predicate=c.predicate||null,this.represent=c.represent||null,this.representName=c.representName||null,this.defaultStyle=c.defaultStyle||null,this.multi=c.multi||!1,this.styleAliases=r(c.styleAliases||null),n.indexOf(this.kind)===-1)throw new t('Unknown kind "'+this.kind+'" is specified for "'+a+'" YAML type.')}return Dd=s,Dd}var _d,Xg;function Jg(){if(Xg)return _d;Xg=1;const t=da(),e=Mn();function n(a,c){const u=[];return a[c].forEach(function(f){let h=u.length;u.forEach(function(g,b){g.tag===f.tag&&g.kind===f.kind&&g.multi===f.multi&&(h=b)}),u[h]=f}),u}function r(){const a={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}};function c(u){u.multi?(a.multi[u.kind].push(u),a.multi.fallback.push(u)):a[u.kind][u.tag]=a.fallback[u.tag]=u}for(let u=0,f=arguments.length;u=48&&h<=57||h>=65&&h<=70||h>=97&&h<=102}function r(h){return h>=48&&h<=55}function s(h){return h>=48&&h<=57}function a(h){if(h===null)return!1;const g=h.length;let b=0,v=!1;if(!g)return!1;let w=h[b];if((w==="-"||w==="+")&&(w=h[++b]),w==="0"){if(b+1===g)return!0;if(w=h[++b],w==="b"){for(b++;b=0?"0b"+h.toString(2):"-0b"+h.toString(2).slice(1)},octal:function(h){return h>=0?"0o"+h.toString(8):"-0o"+h.toString(8).slice(1)},decimal:function(h){return h.toString(10)},hexadecimal:function(h){return h>=0?"0x"+h.toString(16).toUpperCase():"-0x"+h.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),zd}var Ud,d0;function f0(){if(d0)return Ud;d0=1;const t=ua(),e=Mn(),n=new RegExp("^(?:[-+]?(?:[0-9]+)(?:\\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"),r=new RegExp("^(?:[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function s(h){return h===null||!n.test(h)?!1:isFinite(parseFloat(h,10))?!0:r.test(h)}function a(h){let g=h.toLowerCase();const b=g[0]==="-"?-1:1;return"+-".indexOf(g[0])>=0&&(g=g.slice(1)),g===".inf"?b===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:g===".nan"?NaN:b*parseFloat(g,10)}const c=/^[-+]?[0-9]+e/;function u(h,g){if(isNaN(h))switch(g){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===h)switch(g){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===h)switch(g){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(t.isNegativeZero(h))return"-0.0";const b=h.toString(10);return c.test(b)?b.replace("e",".e"):b}function f(h){return Object.prototype.toString.call(h)==="[object Number]"&&(h%1!==0||t.isNegativeZero(h))}return Ud=new e("tag:yaml.org,2002:float",{kind:"scalar",resolve:s,construct:a,predicate:f,represent:u,defaultStyle:"lowercase"}),Ud}var Vd,h0;function p0(){return h0||(h0=1,Vd=r0().extend({implicit:[l0(),o0(),u0(),f0()]})),Vd}var Fd,m0;function g0(){return m0||(m0=1,Fd=p0()),Fd}var Pd,y0;function b0(){if(y0)return Pd;y0=1;const t=Mn(),e=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),n=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function r(c){return c===null?!1:e.exec(c)!==null||n.exec(c)!==null}function s(c){let u=0,f=null,h=e.exec(c);if(h===null&&(h=n.exec(c)),h===null)throw new Error("Date resolve error");const g=+h[1],b=+h[2]-1,v=+h[3];if(!h[4])return new Date(Date.UTC(g,b,v));const w=+h[4],A=+h[5],C=+h[6];if(h[7]){for(u=h[7].slice(0,3);u.length<3;)u+="0";u=+u}if(h[9]){const D=+h[10],O=+(h[11]||0);f=(D*60+O)*6e4,h[9]==="-"&&(f=-f)}const E=new Date(Date.UTC(g,b,v,w,A,C,u));return f&&E.setTime(E.getTime()-f),E}function a(c){return c.toISOString()}return Pd=new t("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:r,construct:s,instanceOf:Date,represent:a}),Pd}var Yd,x0;function v0(){if(x0)return Yd;x0=1;const t=Mn();function e(n){return n==="<<"||n===null}return Yd=new t("tag:yaml.org,2002:merge",{kind:"scalar",resolve:e}),Yd}var Kd,w0;function S0(){if(w0)return Kd;w0=1;const t=Mn(),e=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= +\r`;function n(c){if(c===null)return!1;let u=0;const f=c.length,h=e;for(let g=0;g64)){if(b<0)return!1;u+=6}}return u%8===0}function r(c){const u=c.replace(/[\r\n=]/g,""),f=u.length,h=e;let g=0;const b=[];for(let w=0;w>16&255),b.push(g>>8&255),b.push(g&255)),g=g<<6|h.indexOf(u.charAt(w));const v=f%4*6;return v===0?(b.push(g>>16&255),b.push(g>>8&255),b.push(g&255)):v===18?(b.push(g>>10&255),b.push(g>>2&255)):v===12&&b.push(g>>4&255),new Uint8Array(b)}function s(c){let u="",f=0;const h=c.length,g=e;for(let v=0;v>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]),f=(f<<8)+c[v];const b=h%3;return b===0?(u+=g[f>>18&63],u+=g[f>>12&63],u+=g[f>>6&63],u+=g[f&63]):b===2?(u+=g[f>>10&63],u+=g[f>>4&63],u+=g[f<<2&63],u+=g[64]):b===1&&(u+=g[f>>2&63],u+=g[f<<4&63],u+=g[64],u+=g[64]),u}function a(c){return Object.prototype.toString.call(c)==="[object Uint8Array]"}return Kd=new t("tag:yaml.org,2002:binary",{kind:"scalar",resolve:n,construct:r,predicate:a,represent:s}),Kd}var Gd,A0;function k0(){if(A0)return Gd;A0=1;const t=Mn(),e=Object.prototype.hasOwnProperty,n=Object.prototype.toString;function r(a){if(a===null)return!0;const c={},u=a;for(let f=0,h=u.length;f=48&&x<=57)return x-48;const U=x|32;return U>=97&&U<=102?U-97+10:-1}function M(x){return x===120?2:x===117?4:x===85?8:0}function G(x){return x>=48&&x<=57?x-48:-1}function Y(x){switch(x){case 48:return"\0";case 97:return"\x07";case 98:return"\b";case 116:return" ";case 9:return" ";case 110:return` +`;case 118:return"\v";case 102:return"\f";case 114:return"\r";case 101:return"\x1B";case 32:return" ";case 34:return'"';case 47:return"/";case 92:return"\\";case 78:return"…";case 95:return" ";case 76:return"\u2028";case 80:return"\u2029";default:return""}}function B(x){return x<=65535?String.fromCharCode(x):String.fromCharCode((x-65536>>10)+55296,(x-65536&1023)+56320)}function K(x,U,pe){U==="__proto__"?Object.defineProperty(x,U,{configurable:!0,enumerable:!0,writable:!0,value:pe}):x[U]=pe}const ee=new Array(256),be=new Array(256);for(let x=0;x<256;x++)ee[x]=Y(x)?1:0,be[x]=Y(x);function ce(x,U){this.input=x,this.filename=U.filename||null,this.schema=U.schema||r,this.onWarning=U.onWarning||null,this.legacy=U.legacy||!1,this.json=U.json||!1,this.listener=U.listener||null,this.maxDepth=typeof U.maxDepth=="number"?U.maxDepth:100,this.maxTotalMergeKeys=typeof U.maxTotalMergeKeys=="number"?U.maxTotalMergeKeys:1e4,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=x.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.depth=0,this.totalMergeKeys=0,this.firstTabInLine=-1,this.documents=[],this.anchorMapTransactions=[]}function ge(x,U){const pe={name:x.filename,buffer:x.input.slice(0,-1),position:x.position,line:x.line,column:x.position-x.lineStart};return pe.snippet=n(pe),new e(U,pe)}function q(x,U){throw ge(x,U)}function J(x,U){x.onWarning&&x.onWarning.call(null,ge(x,U))}function oe(x,U,pe){const ue=x.anchorMapTransactions;if(ue.length!==0){const X=ue[ue.length-1];s.call(X,U)||(X[U]={existed:s.call(x.anchorMap,U),value:x.anchorMap[U]})}x.anchorMap[U]=pe}function he(x){x.anchorMapTransactions.push(Object.create(null))}function Se(x){const U=x.anchorMapTransactions.pop(),pe=x.anchorMapTransactions;if(pe.length===0)return;const ue=pe[pe.length-1],X=Object.keys(U);for(let k=0,V=X.length;k=0;ue-=1){const X=U[pe[ue]];X.existed?x.anchorMap[pe[ue]]=X.value:delete x.anchorMap[pe[ue]]}}function z(x){return{position:x.position,line:x.line,lineStart:x.lineStart,lineIndent:x.lineIndent,firstTabInLine:x.firstTabInLine,tag:x.tag,anchor:x.anchor,kind:x.kind,result:x.result}}function me(x,U){x.position=U.position,x.line=U.line,x.lineStart=U.lineStart,x.lineIndent=U.lineIndent,x.firstTabInLine=U.firstTabInLine,x.tag=U.tag,x.anchor=U.anchor,x.kind=U.kind,x.result=U.result}const ne={YAML:function(U,pe,ue){U.version!==null&&q(U,"duplication of %YAML directive"),ue.length!==1&&q(U,"YAML directive accepts exactly one argument");const X=/^([0-9]+)\.([0-9]+)$/.exec(ue[0]);X===null&&q(U,"ill-formed argument of the YAML directive");const k=parseInt(X[1],10),V=parseInt(X[2],10);k!==1&&q(U,"unacceptable YAML version of the document"),U.version=ue[0],U.checkLineBreaks=V<2,V!==1&&V!==2&&J(U,"unsupported YAML version of the document")},TAG:function(U,pe,ue){let X;ue.length!==2&&q(U,"TAG directive accepts exactly two arguments");const k=ue[0];X=ue[1],C.test(k)||q(U,"ill-formed tag handle (first argument) of the TAG directive"),s.call(U.tagMap,k)&&q(U,'there is a previously declared suffix for "'+k+'" tag handle'),E.test(X)||q(U,"ill-formed tag prefix (second argument) of the TAG directive");try{X=decodeURIComponent(X)}catch{q(U,"tag prefix is malformed: "+X)}U.tagMap[k]=X}};function Ce(x,U,pe,ue){if(U=32&&W<=1114111||q(x,"expected valid JSON character")}else v.test(X)&&q(x,"the stream contains non-printable characters");x.result+=X}}function Re(x){x.totalMergeKeys++,x.maxTotalMergeKeys!==-1&&x.totalMergeKeys>x.maxTotalMergeKeys&&q(x,"merge keys exceeded maxTotalMergeKeys ("+x.maxTotalMergeKeys+")")}function qe(x,U,pe,ue){t.isObject(pe)||q(x,"cannot merge mappings; the provided source object is unacceptable"),Re(x);const X=Object.keys(pe);for(let k=0,V=X.length;k100&&q(x,"abnormal merge sequence size");for(let F=0,de=k.length;F1&&(x.result+=t.repeat(` +`,U-1))}function yt(x,U,pe){let ue,X,k,V,W,we;const F=x.kind,de=x.result;let ae=x.input.charCodeAt(x.position);if(R(ae)||_(ae)||ae===35||ae===38||ae===42||ae===33||ae===124||ae===62||ae===39||ae===34||ae===37||ae===64||ae===96)return!1;if(ae===63||ae===45){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))return!1}for(x.kind="scalar",x.result="",ue=X=x.position,k=!1;ae!==0;){if(ae===58){const Ae=x.input.charCodeAt(x.position+1);if(R(Ae)||pe&&_(Ae))break}else if(ae===35){const Ae=x.input.charCodeAt(x.position-1);if(R(Ae))break}else{if(x.position===x.lineStart&&dt(x)||pe&&_(ae))break;if(O(ae))if(V=x.line,W=x.lineStart,we=x.lineIndent,Be(x,!1,-1),x.lineIndent>=U){k=!0,ae=x.input.charCodeAt(x.position);continue}else{x.position=X,x.line=V,x.lineStart=W,x.lineIndent=we;break}}k&&(Ce(x,ue,X,!1),At(x,x.line-V),ue=X=x.position,k=!1),j(ae)||(X=x.position+1),ae=x.input.charCodeAt(++x.position)}return Ce(x,ue,X,!1),x.result?!0:(x.kind=F,x.result=de,!1)}function Ge(x,U){let pe,ue,X=x.input.charCodeAt(x.position);if(X!==39)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(X=x.input.charCodeAt(x.position))!==0;)if(X===39)if(Ce(x,pe,x.position,!0),X=x.input.charCodeAt(++x.position),X===39)pe=x.position,x.position++,ue=x.position;else return!0;else O(X)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a single quoted scalar"):(x.position++,j(X)||(ue=x.position));q(x,"unexpected end of the stream within a single quoted scalar")}function Q(x,U){let pe,ue,X,k=x.input.charCodeAt(x.position);if(k!==34)return!1;for(x.kind="scalar",x.result="",x.position++,pe=ue=x.position;(k=x.input.charCodeAt(x.position))!==0;){if(k===34)return Ce(x,pe,x.position,!0),x.position++,!0;if(k===92){if(Ce(x,pe,x.position,!0),k=x.input.charCodeAt(++x.position),O(k))Be(x,!1,U);else if(k<256&&ee[k])x.result+=be[k],x.position++;else if((X=M(k))>0){let V=X,W=0;for(;V>0;V--)k=x.input.charCodeAt(++x.position),(X=L(k))>=0?W=(W<<4)+X:q(x,"expected hexadecimal character");x.result+=B(W),x.position++}else q(x,"unknown escape sequence");pe=ue=x.position}else O(k)?(Ce(x,pe,ue,!0),At(x,Be(x,!1,U)),pe=ue=x.position):x.position===x.lineStart&&dt(x)?q(x,"unexpected end of the document within a double quoted scalar"):(x.position++,j(k)||(ue=x.position))}q(x,"unexpected end of the stream within a double quoted scalar")}function re(x,U){let pe=!0,ue,X,k;const V=x.tag;let W;const we=x.anchor;let F,de,ae,Ae;const Ee=Object.create(null);let Te,Le,ze,Ve=x.input.charCodeAt(x.position);if(Ve===91)F=93,Ae=!1,W=[];else if(Ve===123)F=125,Ae=!0,W={};else return!1;for(x.anchor!==null&&oe(x,x.anchor,W),Ve=x.input.charCodeAt(++x.position);Ve!==0;){if(Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===F)return x.position++,x.tag=V,x.anchor=we,x.kind=Ae?"mapping":"sequence",x.result=W,!0;if(pe?Ve===44&&q(x,"expected the node content, but found ','"):q(x,"missed comma between flow collection entries"),Le=Te=ze=null,de=ae=!1,Ve===63){const Dt=x.input.charCodeAt(x.position+1);R(Dt)&&(de=ae=!0,x.position++,Be(x,!0,U))}ue=x.line,X=x.lineStart,k=x.position,ft(x,U,a,!1,!0),Le=x.tag,Te=x.result,Be(x,!0,U),Ve=x.input.charCodeAt(x.position),(ae||x.line===ue)&&Ve===58&&(de=!0,Ve=x.input.charCodeAt(++x.position),Be(x,!0,U),ft(x,U,a,!1,!0),ze=x.result),Ae?He(x,W,Ee,Le,Te,ze,ue,X,k):de?W.push(He(x,null,Ee,Le,Te,ze,ue,X,k)):W.push(Te),Be(x,!0,U),Ve=x.input.charCodeAt(x.position),Ve===44?(pe=!0,Ve=x.input.charCodeAt(++x.position)):pe=!1}q(x,"unexpected end of the stream within a flow collection")}function ve(x,U){let pe,ue=h,X=!1,k=!1,V=U,W=0,we=!1,F,de=x.input.charCodeAt(x.position);if(de===124)pe=!1;else if(de===62)pe=!0;else return!1;for(x.kind="scalar",x.result="";de!==0;)if(de=x.input.charCodeAt(++x.position),de===43||de===45)h===ue?ue=de===43?b:g:q(x,"repeat of a chomping mode identifier");else if((F=G(de))>=0)F===0?q(x,"bad explicit indentation width of a block scalar; it cannot be less than one"):k?q(x,"repeat of an indentation width identifier"):(V=U+F-1,k=!0);else break;if(j(de)){do de=x.input.charCodeAt(++x.position);while(j(de));if(de===35)do de=x.input.charCodeAt(++x.position);while(!O(de)&&de!==0)}for(;de!==0;){for(Je(x),x.lineIndent=0,de=x.input.charCodeAt(x.position);(!k||x.lineIndentV&&(V=x.lineIndent),O(de)){W++;continue}if(!k&&V===0&&q(x,"missing indentation for block scalar"),x.lineIndentU)&&V!==0)q(x,"bad indentation of a sequence entry");else if(x.lineIndentU)&&(Te&&(X=x.line,k=x.lineStart,V=x.position),ft(x,U,f,!0,ue)&&(Te?Ae=x.result:Ee=x.result),Te||(He(x,F,de,ae,Ae,Ee,X,k,V),ae=Ae=Ee=null),Be(x,!0,-1),ze=x.input.charCodeAt(x.position)),(x.line===Dt||x.lineIndent>U)&&ze!==0)q(x,"bad indentation of a mapping entry");else if(x.lineIndent=x.maxDepth&&q(x,"nesting exceeded maxDepth ("+x.maxDepth+")"),x.depth+=1,x.listener!==null&&x.listener("open",x),x.tag=null,x.anchor=null,x.kind=null,x.result=null;const Te=k=V=f===pe||u===pe;if(ue&&Be(x,!0,-1)&&(we=!0,x.lineIndent>U?W=1:x.lineIndent===U?W=0:x.lineIndentU?W=1:x.lineIndent===U?W=0:x.lineIndent tag; it should be "scalar", not "'+x.kind+'"');for(let Le=0,ze=x.implicitTypes.length;Le"),x.result!==null&&ae.kind!==x.kind&&q(x,"unacceptable node kind for !<"+x.tag+'> tag; it should be "'+ae.kind+'", not "'+x.kind+'"'),ae.resolve(x.result,x.tag)?(x.result=ae.construct(x.result,x.tag),x.anchor!==null&&oe(x,x.anchor,x.result)):q(x,"cannot resolve a node with !<"+x.tag+"> explicit tag")}return x.listener!==null&&x.listener("close",x),x.depth-=1,x.tag!==null||x.anchor!==null||F}function ni(x){const U=x.position;let pe=!1,ue;for(x.version=null,x.checkLineBreaks=x.legacy,x.tagMap=Object.create(null),x.anchorMap=Object.create(null);(ue=x.input.charCodeAt(x.position))!==0&&(Be(x,!0,-1),ue=x.input.charCodeAt(x.position),!(x.lineIndent>0||ue!==37));){pe=!0,ue=x.input.charCodeAt(++x.position);let X=x.position;for(;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);const k=x.input.slice(X,x.position),V=[];for(k.length<1&&q(x,"directive name must not be less than one character in length");ue!==0;){for(;j(ue);)ue=x.input.charCodeAt(++x.position);if(ue===35){do ue=x.input.charCodeAt(++x.position);while(ue!==0&&!O(ue));break}if(O(ue))break;for(X=x.position;ue!==0&&!R(ue);)ue=x.input.charCodeAt(++x.position);V.push(x.input.slice(X,x.position))}ue!==0&&Je(x),s.call(ne,k)?ne[k](x,k,V):J(x,'unknown document directive "'+k+'"')}if(Be(x,!0,-1),x.lineIndent===0&&x.input.charCodeAt(x.position)===45&&x.input.charCodeAt(x.position+1)===45&&x.input.charCodeAt(x.position+2)===45?(x.position+=3,Be(x,!0,-1)):pe&&q(x,"directives end mark is expected"),ft(x,x.lineIndent-1,f,!1,!0),Be(x,!0,-1),x.checkLineBreaks&&w.test(x.input.slice(U,x.position))&&J(x,"non-ASCII line breaks are interpreted as content"),x.documents.push(x.result),x.position===x.lineStart&&dt(x)){x.input.charCodeAt(x.position)===46&&(x.position+=3,Be(x,!0,-1));return}x.position"u"&&(pe=U,U=null);const ue=Vn(x,pe);if(typeof U!="function")return ue;for(let X=0,k=ue.length;X=32&&k<=126||k>=161&&k<=55295&&k!==8232&&k!==8233||k>=57344&&k<=65533&&k!==a||k>=65536&&k<=1114111}function qe(k){return Re(k)&&k!==a&&k!==f&&k!==u}function He(k,V,W){const we=qe(k),F=we&&!Ce(k);return(W?we:we&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be)&&k!==v&&!(V===j&&!F)||qe(V)&&!Ce(V)&&k===v||V===j&&F}function Je(k){return Re(k)&&k!==a&&!Ce(k)&&k!==O&&k!==L&&k!==j&&k!==D&&k!==G&&k!==Y&&k!==K&&k!==be&&k!==v&&k!==A&&k!==E&&k!==g&&k!==ee&&k!==R&&k!==_&&k!==C&&k!==b&&k!==w&&k!==M&&k!==B}function Be(k){return!Ce(k)&&k!==j}function dt(k,V){const W=k.charCodeAt(V);let we;return W>=55296&&W<=56319&&V+1=56320&&we<=57343)?(W-55296)*1024+we-56320+65536:W}function At(k){return/^\n* /.test(k)}const yt=1,Ge=2,Q=3,re=4,ve=5;function Ne(k,V,W,we,F,de,ae,Ae){let Ee,Te=0,Le=null,ze=!1,Ve=!1;const Dt=we!==-1;let Fn=-1,jn=Je(dt(k,0))&&Be(dt(k,k.length-1));if(V||ae)for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}else{for(Ee=0;Ee=65536?Ee+=2:Ee++){if(Te=dt(k,Ee),Te===u)ze=!0,Dt&&(Ve=Ve||Ee-Fn-1>we&&k[Fn+1]!==" ",Fn=Ee);else if(!Re(Te))return ve;jn=jn&&He(Te,Le,Ae),Le=Te}Ve=Ve||Dt&&Ee-Fn-1>we&&k[Fn+1]!==" "}return!ze&&!Ve?jn&&!ae&&!F(k)?yt:de===Se?ve:Ge:W>9&&At(k)?ve:ae?de===Se?ve:Ge:Ve?re:Q}function $e(k,V,W,we,F){k.dump=(function(){if(V.length===0)return k.quotingType===Se?'""':"''";if(!k.noCompatMode&&(ge.indexOf(V)!==-1||q.test(V)))return k.quotingType===Se?'"'+V+'"':"'"+V+"'";const de=k.indent*Math.max(1,W),ae=k.lineWidth===-1?-1:Math.max(Math.min(k.lineWidth,40),k.lineWidth-de),Ae=we||k.flowLevel>-1&&W>=k.flowLevel;function Ee(Te){return ne(k,Te)}switch(Ne(V,Ae,k.indent,ae,Ee,k.quotingType,k.forceQuotes&&!we,F)){case yt:return V;case Ge:return"'"+V.replace(/'/g,"''")+"'";case Q:return"|"+We(V,k.indent)+vt(z(V,de));case re:return">"+We(V,k.indent)+vt(z(ti(V,ae),de));case ve:return'"'+ft(V)+'"';default:throw new e("impossible error: invalid scalar style")}})()}function We(k,V){const W=At(k)?String(V):"",we=k[k.length-1]===` +`,de=we&&(k[k.length-2]===` `||k===` -`)?"+":xe?"":"-";return Z+ce+` -`}function Et(k){return k[k.length-1]===` -`?k.slice(0,-1):k}function ti(k,F){const Z=/(\n+)([^\n]*)/g;let xe=(function(){let we=k.indexOf(` -`);return we=we!==-1?we:k.length,Z.lastIndex=we,Tn(k.slice(0,we),F)})(),P=k[0]===` -`||k[0]===" ",ce,le;for(;le=Z.exec(k);){const we=le[1],Oe=le[2];ce=Oe[0]===" ",xe+=we+(!P&&!ce&&Oe!==""?` -`:"")+Tn(Oe,F),P=ce}return xe}function Tn(k,F){if(k===""||k[0]===" ")return k;const Z=/ [^ ]/g;let xe,P=0,ce,le=0,we=0,Oe="";for(;xe=Z.exec(k);)we=xe.index,we-P>F&&(ce=le>P?le:we,Oe+=` -`+k.slice(P,ce),P=ce+1),le=we;return Oe+=` -`,k.length-P>F&&le>P?Oe+=k.slice(P,le)+` -`+k.slice(le+1):Oe+=k.slice(P),Oe.slice(1)}function ht(k){let F="",Z=0;for(let xe=0;xe=65536?xe+=2:xe++){Z=ut(k,xe);const P=me[Z];!P&&_e(Z)?(F+=k[xe],Z>=65536&&(F+=k[xe+1])):F+=P||oe(Z)}return F}function ni(k,F,Z){let xe="";const P=k.tag;for(let ce=0,le=Z.length;ce"u"&&V(k,F,null,!1,!1))&&(xe!==""&&(xe+=","+(k.condenseFlow?"":" ")),xe+=k.dump)}k.tag=P,k.dump="["+xe+"]"}function Vn(k,F,Z,xe){let P="";const ce=k.tag;for(let le=0,we=Z.length;le"u"&&V(k,F+1,null,!0,!0,!1,!0))&&((!xe||P!=="")&&(P+=he(k,F)),k.dump&&u===k.dump.charCodeAt(0)?P+="-":P+="- ",P+=k.dump)}k.tag=ce,k.dump=P||"[]"}function qn(k,F,Z){let xe="";const P=k.tag,ce=Object.keys(Z);for(let le=0,we=ce.length;le1024&&(Oe+="? "),Oe+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),V(k,F,Be,!1,!1)&&(Oe+=k.dump,xe+=Oe))}k.tag=P,k.dump="{"+xe+"}"}function St(k,F,Z,xe){let P="";const ce=k.tag,le=Object.keys(Z);if(k.sortKeys===!0)le.sort();else if(typeof k.sortKeys=="function")le.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let we=0,Oe=le.length;we1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=he(k,F)),V(k,F+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,P+=Te)}k.tag=ce,k.dump=P||"{}"}function x(k,F,Z){const xe=Z?k.explicitTypes:k.implicitTypes;for(let P=0,ce=xe.length;P tag resolver accepts not "'+we+'" style');k.dump=Oe}return!0}}return!1}function V(k,F,Z,xe,P,ce,le){k.tag=null,k.dump=Z,x(k,Z,!1)||x(k,Z,!0);const we=r.call(k.dump),Oe=xe;xe&&(xe=k.flowLevel<0||k.flowLevel>F);const Te=we==="[object Object]"||we==="[object Array]";let Be,ze;if(Te&&(Be=k.duplicates.indexOf(Z),ze=Be!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&F>0)&&(P=!1),ze&&k.usedDuplicates[Be])k.dump="*ref_"+Be;else{if(Te&&ze&&!k.usedDuplicates[Be]&&(k.usedDuplicates[Be]=!0),we==="[object Object]")xe&&Object.keys(k.dump).length!==0?(St(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(qn(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object Array]")xe&&k.dump.length!==0?(k.noArrayIndent&&!le&&F>0?Vn(k,F-1,k.dump,P):Vn(k,F,k.dump,P),ze&&(k.dump="&ref_"+Be+k.dump)):(ni(k,F,k.dump),ze&&(k.dump="&ref_"+Be+" "+k.dump));else if(we==="[object String]")k.tag!=="?"&&Ge(k,k.dump,F,ce,Oe);else{if(we==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+we)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,F){const Z=[],xe=[];ae(k,Z,xe);const P=xe.length;for(let ce=0;cee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",O=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",E=J=>{const U="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${U} ${K[J.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((J,[U,B])=>(In.getHttpMethods(B).forEach(K=>{const W=B[K];(W?.tags||["default"]).forEach(me=>{J[me]||(J[me]=[]),J[me].push({path:U,method:K,operation:W})})}),J),{}),M=u.trim().toLowerCase(),_=M.length>0,q=Object.entries(j).reduce((J,[U,B])=>{const K=B.filter(W=>`${W.method} ${W.path} ${W.operation?.summary||""} ${U}`.toLowerCase().includes(M));return K.length&&(J[U]=K),J},{}),R=J=>{const U=new Set(w);U.has(J)?U.delete(J):U.add(J),s||g(U),a?.([...U])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:J=>f(J.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((J,U)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:J.url}),J.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:J.description})]},`${J.url}:${U}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${O}`,children:c?.endpoints||"Endpoints"}),Object.keys(q).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${O}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(q).map(([J,U])=>{const B=_||w.has(J);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>R(J),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:J==="default"?c?.generalTag||"General":J}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:U.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:U.map(({path:K,method:W,operation:ye})=>{const me=n?.path===K&&n?.method===W;return p.jsxs("button",{type:"button","data-selected-endpoint":me?"true":void 0,onClick:()=>e(K,W),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${me?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:me?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:E(W),children:W.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${me?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),ye?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:ye.summary})]},`${W}-${K}`)})})]},J)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const O of s.parameters){const D=O.in==="header"?r.headers?.[O.name]:O.in==="cookie"?r.cookies?.[O.name]:r.parameters?.[O.name];if(!(D===void 0||D===""))if(O.in==="path")u=u.replace(`{${O.name}}`,Nk(O,D));else if(O.in==="query")for(const[E,j]of Tk(O,D))f.push(`${encodeURIComponent(E)}=${D0(j,O.allowReserved)}`);else O.in==="header"?h[O.name]=_0(D,O.explode):O.in==="cookie"&&g.push(`${O.name}=${encodeURIComponent(_0(D,O.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const O=r.contentType||"application/json";if(b=r.body,O==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([E,j])=>Array.isArray(j)?j.map(M=>`${encodeURIComponent(E)}=${encodeURIComponent(cn(M))}`):[`${encodeURIComponent(E)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=O}else if(O.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const E=new FormData;for(const[j,M]of Object.entries(D))Array.isArray(M)?M.forEach(_=>E.append(j,cn(_))):E.append(j,cn(M));w=E}else w=r.body;v="multipart"}else w=r.body,v=O.includes("json")?"json":"text",h["Content-Type"]=O}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ +`)?"+":we?"":"-";return W+de+` +`}function vt(k){return k[k.length-1]===` +`?k.slice(0,-1):k}function ti(k,V){const W=/(\n+)([^\n]*)/g;let we=(function(){let Ae=k.indexOf(` +`);return Ae=Ae!==-1?Ae:k.length,W.lastIndex=Ae,Tn(k.slice(0,Ae),V)})(),F=k[0]===` +`||k[0]===" ",de,ae;for(;ae=W.exec(k);){const Ae=ae[1],Ee=ae[2];de=Ee[0]===" ",we+=Ae+(!F&&!de&&Ee!==""?` +`:"")+Tn(Ee,V),F=de}return we}function Tn(k,V){if(k===""||k[0]===" ")return k;const W=/ [^ ]/g;let we,F=0,de,ae=0,Ae=0,Ee="";for(;we=W.exec(k);)Ae=we.index,Ae-F>V&&(de=ae>F?ae:Ae,Ee+=` +`+k.slice(F,de),F=de+1),ae=Ae;return Ee+=` +`,k.length-F>V&&ae>F?Ee+=k.slice(F,ae)+` +`+k.slice(ae+1):Ee+=k.slice(F),Ee.slice(1)}function ft(k){let V="",W=0;for(let we=0;we=65536?we+=2:we++){W=dt(k,we);const F=ce[W];!F&&Re(W)?(V+=k[we],W>=65536&&(V+=k[we+1])):V+=F||oe(W)}return V}function ni(k,V,W){let we="";const F=k.tag;for(let de=0,ae=W.length;de"u"&&U(k,V,null,!1,!1))&&(we!==""&&(we+=","+(k.condenseFlow?"":" ")),we+=k.dump)}k.tag=F,k.dump="["+we+"]"}function Vn(k,V,W,we){let F="";const de=k.tag;for(let ae=0,Ae=W.length;ae"u"&&U(k,V+1,null,!0,!0,!1,!0))&&((!we||F!=="")&&(F+=me(k,V)),k.dump&&u===k.dump.charCodeAt(0)?F+="-":F+="- ",F+=k.dump)}k.tag=de,k.dump=F||"[]"}function qn(k,V,W){let we="";const F=k.tag,de=Object.keys(W);for(let ae=0,Ae=de.length;ae1024&&(Ee+="? "),Ee+=k.dump+(k.condenseFlow?'"':"")+":"+(k.condenseFlow?"":" "),U(k,V,Le,!1,!1)&&(Ee+=k.dump,we+=Ee))}k.tag=F,k.dump="{"+we+"}"}function kt(k,V,W,we){let F="";const de=k.tag,ae=Object.keys(W);if(k.sortKeys===!0)ae.sort();else if(typeof k.sortKeys=="function")ae.sort(k.sortKeys);else if(k.sortKeys)throw new e("sortKeys must be a boolean or a function");for(let Ae=0,Ee=ae.length;Ae1024;Ve&&(k.dump&&u===k.dump.charCodeAt(0)?Te+="?":Te+="? "),Te+=k.dump,Ve&&(Te+=me(k,V)),U(k,V+1,ze,!0,Ve)&&(k.dump&&u===k.dump.charCodeAt(0)?Te+=":":Te+=": ",Te+=k.dump,F+=Te)}k.tag=de,k.dump=F||"{}"}function x(k,V,W){const we=W?k.explicitTypes:k.implicitTypes;for(let F=0,de=we.length;F tag resolver accepts not "'+Ae+'" style');k.dump=Ee}return!0}}return!1}function U(k,V,W,we,F,de,ae){k.tag=null,k.dump=W,x(k,W,!1)||x(k,W,!0);const Ae=r.call(k.dump),Ee=we;we&&(we=k.flowLevel<0||k.flowLevel>V);const Te=Ae==="[object Object]"||Ae==="[object Array]";let Le,ze;if(Te&&(Le=k.duplicates.indexOf(W),ze=Le!==-1),(k.tag!==null&&k.tag!=="?"||ze||k.indent!==2&&V>0)&&(F=!1),ze&&k.usedDuplicates[Le])k.dump="*ref_"+Le;else{if(Te&&ze&&!k.usedDuplicates[Le]&&(k.usedDuplicates[Le]=!0),Ae==="[object Object]")we&&Object.keys(k.dump).length!==0?(kt(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(qn(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object Array]")we&&k.dump.length!==0?(k.noArrayIndent&&!ae&&V>0?Vn(k,V-1,k.dump,F):Vn(k,V,k.dump,F),ze&&(k.dump="&ref_"+Le+k.dump)):(ni(k,V,k.dump),ze&&(k.dump="&ref_"+Le+" "+k.dump));else if(Ae==="[object String]")k.tag!=="?"&&$e(k,k.dump,V,de,Ee);else{if(Ae==="[object Undefined]")return!1;if(k.skipInvalid)return!1;throw new e("unacceptable kind of an object to dump "+Ae)}if(k.tag!==null&&k.tag!=="?"){let Ve=encodeURI(k.tag[0]==="!"?k.tag.slice(1):k.tag).replace(/!/g,"%21");k.tag[0]==="!"?Ve="!"+Ve:Ve.slice(0,18)==="tag:yaml.org,2002:"?Ve="!!"+Ve.slice(18):Ve="!<"+Ve+">",k.dump=Ve+" "+k.dump}}return!0}function pe(k,V){const W=[],we=[];ue(k,W,we);const F=we.length;for(let de=0;dee[r])}static decodePointerToken(e){return decodeURIComponent(e).replace(/~1/g,"/").replace(/~0/g,"~")}static encodePointerToken(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}static resolveReference(e,n){if(!n.startsWith("#/"))throw new Error(`Only local references are supported synchronously; bundle external references first: ${n}`);const r=n.substring(2).split("/").map(TA.decodePointerToken);let s=e;for(const a of r){if(s===null||typeof s!="object"||!(a in s))throw new Error(`Reference not found: ${n}`);s=s[a]}return s}static isReference(e){return!!e&&typeof e=="object"&&"$ref"in e&&typeof e.$ref=="string"}};class In{static async parseSpec(e){return Ii.parseSpec(e)}static getHttpMethods(e){return Ii.getHttpMethods(e)}static getMethodColor(e,n){const a=n==="dark"?{get:"text-blue-300 bg-blue-900/30 border-blue-700",post:"text-green-300 bg-green-900/30 border-green-700",put:"text-orange-300 bg-orange-900/30 border-orange-700",delete:"text-red-300 bg-red-900/30 border-red-700",patch:"text-purple-300 bg-purple-900/30 border-purple-700",options:"text-cyan-100 bg-cyan-800/50 border-cyan-500",head:"text-gray-300 bg-gray-700/50 border-gray-600",trace:"text-gray-300 bg-gray-700/50 border-gray-600"}:{get:"text-blue-600 bg-blue-50 border-blue-200",post:"text-green-600 bg-green-50 border-green-200",put:"text-orange-600 bg-orange-50 border-orange-200",delete:"text-red-600 bg-red-50 border-red-200",patch:"text-purple-600 bg-purple-50 border-purple-200",options:"text-gray-600 bg-gray-50 border-gray-200",head:"text-gray-600 bg-gray-50 border-gray-200",trace:"text-gray-600 bg-gray-50 border-gray-200"},c=n==="dark"?"text-gray-300 bg-gray-700/50 border-gray-600":"text-gray-600 bg-gray-50 border-gray-200";return a[e.toLowerCase()]||c}static decodePointerToken(e){return Ii.decodePointerToken(e)}static encodePointerToken(e){return Ii.encodePointerToken(e)}static resolveReference(e,n){return Ii.resolveReference(e,n)}static isReference(e){return Ii.isReference(e)}}const pk=({spec:t,onEndpointSelect:e,selectedEndpoint:n=null,theme:r="light",expandedTags:s,onExpandedTagsChange:a,messages:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState(new Set(s?.length?s:["default"])),b=I.useId(),v=I.useRef(null),w=s?new Set(s):h;I.useEffect(()=>{n&&requestAnimationFrame(()=>{v.current?.querySelector('[data-selected-endpoint="true"]')?.scrollIntoView({block:"nearest"})})},[n]);const A=r==="dark"?"bg-gray-900 border-r border-gray-800 text-white":"bg-white border-r border-gray-200 text-gray-700",C=r==="dark"?"bg-gray-800 border-gray-700 text-white placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1":"border-gray-300 text-gray-700 placeholder-gray-400 focus:ring-blue-500 focus:border-blue-500 focus:ring-1",E=r==="dark"?"text-gray-300":"text-gray-500",D=r==="dark"?"bg-gray-800/50 border-gray-700 text-white":"bg-gray-50 border-gray-100 text-gray-700",O=G=>{const Y="text-xs font-bold px-2 py-0.5 rounded border",B={dark:{get:"bg-blue-900/30 border-blue-700 text-blue-200",post:"bg-green-900/30 border-green-700 text-green-200",put:"bg-yellow-900/30 border-yellow-700 text-yellow-200",patch:"bg-purple-900/30 border-purple-700 text-purple-200",delete:"bg-red-900/30 border-red-700 text-red-200",default:"bg-gray-800/50 border-gray-700 text-gray-200"},light:{get:"bg-blue-50 border-blue-200 text-blue-700",post:"bg-green-50 border-green-200 text-green-700",put:"bg-yellow-50 border-yellow-200 text-yellow-700",patch:"bg-purple-50 border-purple-200 text-purple-700",delete:"bg-red-50 border-red-200 text-red-700",default:"bg-gray-100 border-gray-200 text-gray-600"}},K=r==="dark"?B.dark:B.light;return`${Y} ${K[G.toLowerCase()]||K.default}`},j=Object.entries(t.paths).reduce((G,[Y,B])=>(In.getHttpMethods(B).forEach(K=>{const ee=B[K];(ee?.tags||["default"]).forEach(ce=>{G[ce]||(G[ce]=[]),G[ce].push({path:Y,method:K,operation:ee})})}),G),{}),R=u.trim().toLowerCase(),_=R.length>0,L=Object.entries(j).reduce((G,[Y,B])=>{const K=B.filter(ee=>`${ee.method} ${ee.path} ${ee.operation?.summary||""} ${Y}`.toLowerCase().includes(R));return K.length&&(G[Y]=K),G},{}),M=G=>{const Y=new Set(w);Y.has(G)?Y.delete(G):Y.add(G),s||g(Y),a?.([...Y])};return p.jsxs("div",{ref:v,className:`flex h-full w-full min-w-0 flex-col ${A}`,style:{backgroundColor:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:[p.jsxs("div",{className:`border-b p-4 ${r==="dark"?"border-gray-800":"border-gray-100"}`,children:[p.jsx("label",{className:"sr-only",htmlFor:b,children:c?.searchEndpoints||"Search endpoints"}),p.jsxs("div",{className:"relative",children:[p.jsx(Hg,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),p.jsx("input",{id:b,type:"search",placeholder:c?.searchEndpointsPlaceholder||"Search endpoints...",value:u,onChange:G=>f(G.target.value),className:`w-full rounded-lg border py-2 pl-10 pr-4 text-sm transition-colors ${C}`})]})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain",children:p.jsxs("div",{className:"p-4",children:[p.jsxs("div",{className:"mb-6",children:[p.jsx("h3",{className:`mb-2 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.apiInformation||"API Information"}),p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsx("h4",{className:`truncate font-medium ${r==="dark"?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:[c?.versionLabel||"Version"," ",t.info.version]})]}),t.servers&&t.servers.length>0&&p.jsxs("div",{className:`rounded-lg border p-3 ${D}`,children:[p.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[p.jsx(zg,{className:"h-4 w-4 text-gray-400"}),p.jsx("span",{className:"text-sm font-medium",children:c?.servers||"Servers"})]}),p.jsx("div",{className:"space-y-2",children:t.servers.map((G,Y)=>p.jsxs("div",{className:"min-w-0 text-sm",children:[p.jsx("code",{className:`block max-w-full overflow-x-auto rounded px-1.5 py-0.5 text-xs ${r==="dark"?"bg-gray-700/50 text-blue-200":"bg-gray-100 text-blue-600"}`,children:G.url}),G.description&&p.jsx("p",{className:`mt-1.5 ${r==="dark"?"text-gray-300":"text-gray-600"}`,children:G.description})]},`${G.url}:${Y}`))})]})]})]}),p.jsxs("div",{children:[p.jsx("h3",{className:`mb-3 text-xs font-semibold uppercase tracking-wider ${E}`,children:c?.endpoints||"Endpoints"}),Object.keys(L).length===0&&p.jsx("p",{className:`px-2 py-4 text-sm ${E}`,children:c?.noEndpointsMatch||"No endpoints match your search."}),Object.entries(L).map(([G,Y])=>{const B=_||w.has(G);return p.jsxs("div",{className:"mb-4",children:[p.jsxs("button",{type:"button","aria-expanded":B,onClick:()=>M(G),className:`flex min-h-11 w-full items-center gap-2 rounded-lg p-2 text-left transition-colors ${r==="dark"?"hover:bg-gray-800/50 text-white":"hover:bg-gray-50 text-gray-700"}`,children:[B?p.jsx(Bg,{className:"h-4 w-4 shrink-0 text-gray-400"}):p.jsx($g,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx(Vg,{className:"h-4 w-4 shrink-0 text-gray-400"}),p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:G==="default"?c?.generalTag||"General":G}),p.jsx("span",{className:`ml-auto shrink-0 rounded-full px-2 py-0.5 text-xs ${r==="dark"?"bg-gray-800 text-white":"bg-gray-100 text-gray-500"}`,children:Y.length})]}),B&&p.jsx("div",{className:"ml-4 mt-1.5 space-y-1.5 sm:ml-6",children:Y.map(({path:K,method:ee,operation:be})=>{const ce=n?.path===K&&n?.method===ee;return p.jsxs("button",{type:"button","data-selected-endpoint":ce?"true":void 0,onClick:()=>e(K,ee),className:`mb-2 min-h-11 w-full rounded-lg border p-2 text-left transition-all ${ce?r==="dark"?"bg-blue-900/20 border-blue-800/50 shadow-sm":"bg-blue-50 border-blue-100 shadow-sm":r==="dark"?"hover:bg-gray-800/50 border-transparent hover:border-gray-700":"hover:bg-gray-50 border-transparent hover:border-gray-100"}`,style:ce?{color:"var(--flexdoc-sidebar-active-text)"}:void 0,children:[p.jsx("div",{className:"mb-1 flex items-center gap-2",children:p.jsx("span",{className:O(ee),children:ee.toUpperCase()})}),p.jsx("div",{className:`break-all font-mono text-sm ${ce?r==="dark"?"text-blue-300":"text-blue-600":r==="dark"?"text-gray-300":"text-gray-800"}`,children:K}),be?.summary&&p.jsx("div",{className:`mt-1 text-xs ${r==="dark"?"text-gray-400":"text-gray-600"}`,children:be.summary})]},`${ee}-${K}`)})})]},G)})]})]})})]})},Cs=["parameters","requestBody","responses","tryIt","codeSamples"],ef={all:Cs,none:[],minimal:[],documentation:["parameters","requestBody","responses"],interactive:["parameters","requestBody","tryIt","codeSamples"]},mk=["minimal","documentation","interactive"],gk=Object.keys(ef),yk=["light","dark","high-contrast"];function bk(t){return typeof t=="string"?gk.includes(t):Array.isArray(t)&&t.every(e=>typeof e=="string"&&(Cs.includes(e)||mk.includes(e)))}function tf(t,e){return t===void 0&&e!==void 0?Cs.filter(n=>e!=="none"||n!=="responses"):t===void 0?[]:typeof t=="string"?[...ef[t]]:Cs.filter(n=>t.some(r=>r===n||ef[r]?.includes(n)))}function xk(t,e){return`flexdoc:viewer:${encodeURIComponent(e?.trim()||"unknown-host")}:${encodeURIComponent(t?.trim()||"untitled")}`}function fa(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(t);if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.expand!==void 0&&!bk(s.expand)?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.theme!==void 0&&(typeof s.theme!="string"||!yk.includes(s.theme))?{version:1}:s.expandedTags!==void 0&&(!Array.isArray(s.expandedTags)||!s.expandedTags.every(a=>typeof a=="string"))?{version:1}:{version:1,...s.expand!==void 0?{expand:s.expand}:{},...s.sidebarCollapsed!==void 0?{sidebarCollapsed:s.sidebarCollapsed}:{},...s.theme!==void 0?{theme:s.theme}:{},...s.expandedTags!==void 0?{expandedTags:[...new Set(s.expandedTags)]}:{}}}catch{return{version:1}}}function qo(t,e,n,r){const s=typeof window<"u"?window.localStorage:void 0;if(s)try{const a={...fa(t,s)},c=e==="expandedTags"&&Array.isArray(n)?[...new Set(n)]:n;c===void 0?delete a[e]:a[e]=c,a.expand===void 0&&a.sidebarCollapsed===void 0&&a.theme===void 0&&a.expandedTags===void 0?s.removeItem(t):s.setItem(t,JSON.stringify(a))}catch{}}function Mr(t,e){if(e)return Ii.isReference(e)?Ii.resolveReference(t,e.$ref):e}function vk(t,e){const n=t.paths[e];if(!n)throw new Error(`Path not found: ${e}`);return Mr(t,n)}function wk(t,e={}){return t.url.replace(/\{([^}]+)\}/g,(n,r)=>{const s=t.variables?.[r],a=e[r]??s?.default;if(a===void 0)throw new Error(`Missing server variable: ${r}`);if(s?.enum?.length&&!s.enum.includes(a))throw new Error(`Invalid value for server variable ${r}: ${a}`);return a})}function nf(t,e,n){const r=vk(t,e),s=r[n.toLowerCase()];if(!s||typeof s!="object"||!("responses"in s))throw new Error(`Operation not found: ${n.toUpperCase()} ${e}`);const a=[...r.parameters||[],...s.parameters||[]].map(f=>Mr(t,f)).filter(f=>!!f),c=new Map;for(const f of a)c.set(`${f.in}:${f.name}`,f);const u={};for(const[f,h]of Object.entries(s.responses||{})){const g=Mr(t,h);g&&(u[f]=g)}return{path:e,method:n.toUpperCase(),pathItem:r,operation:s,parameters:[...c.values()],requestBody:Mr(t,s.requestBody),responses:u,servers:s.servers||r.servers||t.servers||[],security:s.security!==void 0?s.security:t.security||[]}}function Sk(t,e,n){return nf(t,e,n).parameters}function Ak(t,e){return Mr(t,e.schema)}function kk(t,e){if(e.example!==void 0)return e.example;const n=Ak(t,e);return n?.example!==void 0?n.example:n?.examples?.length?n.examples[0]:n?.default!==void 0?n.default:n?.enum?.length?n.enum[0]:n?.type==="array"?[]:n?.type==="object"?{}:n?.type==="integer"||n?.type==="number"?1:n?.type==="boolean"?!0:""}function Ck(t,e,n){const r=nf(t,e,n),s={parameters:{},headers:{},cookies:{},auth:{}};for(const u of r.parameters){const f=u.in==="header"?s.headers:u.in==="cookie"?s.cookies:s.parameters;f[u.name]=kk(t,u)}const a=r.requestBody,c=a?Object.keys(a.content||{})[0]:void 0;if(c){s.contentType=c;const u=a.content[c],f=Mr(t,u.schema),h=u.examples?Object.values(u.examples)[0]:void 0,g=Mr(t,h),b=u.example??g?.value??f?.example??f?.examples?.[0]??f?.default;s.body=b!==void 0?JSON.stringify(b,null,2):""}return s}function cn(t){return t===null?"null":typeof t=="object"?JSON.stringify(t):String(t)}function rf(t){if(typeof t!="string")return t;const e=t.trim();if(!e||!e.startsWith("[")&&!e.startsWith("{"))return t;try{return JSON.parse(e)}catch{return t}}function D0(t,e=!1){const n=cn(t);return e?encodeURI(n).replace(/%5B/g,"[").replace(/%5D/g,"]"):encodeURIComponent(n)}function _0(t,e=!1){const n=rf(t);if(Array.isArray(n))return n.map(cn).join(",");if(n&&typeof n=="object"){const r=Object.entries(n);return e?r.map(([s,a])=>`${s}=${cn(a)}`).join(","):r.flatMap(([s,a])=>[s,cn(a)]).join(",")}return cn(n)}function Nk(t,e){const n=t.style||"simple",r=t.explode??!1,s=rf(e),a=u=>D0(u,t.allowReserved);if(Array.isArray(s)){const u=s.map(a);return n==="label"?`.${u.join(r?".":",")}`:n==="matrix"?r?u.map(f=>`;${t.name}=${f}`).join(""):`;${t.name}=${u.join(",")}`:u.join(",")}if(s&&typeof s=="object"){const u=Object.entries(s).map(([f,h])=>[a(f),a(h)]);return n==="label"?r?`.${u.map(([f,h])=>`${f}=${h}`).join(".")}`:`.${u.flatMap(([f,h])=>[f,h]).join(",")}`:n==="matrix"?r?u.map(([f,h])=>`;${f}=${h}`).join(""):`;${t.name}=${u.flatMap(([f,h])=>[f,h]).join(",")}`:r?u.map(([f,h])=>`${f}=${h}`).join(","):u.flatMap(([f,h])=>[f,h]).join(",")}const c=a(s);return n==="label"?`.${c}`:n==="matrix"?`;${t.name}=${c}`:c}function Tk(t,e){const n=t.style||"form",r=t.explode??n==="form",s=rf(e);if(n==="deepObject"&&s&&typeof s=="object"&&!Array.isArray(s))return Object.entries(s).map(([a,c])=>[`${t.name}[${a}]`,cn(c)]);if(Array.isArray(s))return n==="spaceDelimited"?[[t.name,s.map(cn).join(" ")]]:n==="pipeDelimited"?[[t.name,s.map(cn).join("|")]]:r?s.map(a=>[t.name,cn(a)]):[[t.name,s.map(cn).join(",")]];if(s&&typeof s=="object"){const a=Object.entries(s);return r?a.map(([c,u])=>[c,cn(u)]):[[t.name,a.flatMap(([c,u])=>[c,cn(u)]).join(",")]]}return[[t.name,cn(s)]]}function jk(t){return typeof globalThis.btoa=="function"?globalThis.btoa(unescape(encodeURIComponent(t))):t}function Ek(t,e){return Object.keys(t).every(n=>!!e[n])}function Ok(t,e,n,r,s,a){if(!e.length||!t.components?.securitySchemes)return;const c=e.find(u=>Object.keys(u).length===0||Ek(u,a))||e[0];for(const u of Object.keys(c)){const f=Mr(t,t.components.securitySchemes[u]),h=a[u];!f||!h||(f.type==="http"&&f.scheme?.toLowerCase()==="bearer"?n.Authorization=`Bearer ${h}`:f.type==="http"&&f.scheme?.toLowerCase()==="basic"?n.Authorization=`Basic ${jk(h)}`:f.type==="apiKey"&&f.in==="header"&&f.name?n[f.name]=h:f.type==="apiKey"&&f.in==="query"&&f.name?r.push(`${encodeURIComponent(f.name)}=${encodeURIComponent(h)}`):f.type==="apiKey"&&f.in==="cookie"&&f.name?s.push(`${f.name}=${encodeURIComponent(h)}`):(f.type==="oauth2"||f.type==="openIdConnect")&&(n.Authorization=`Bearer ${h}`))}}function L0(t){try{const e=JSON.parse(t);return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}catch{return}}function Mk(t,e,n,r={}){const s=nf(t,e,n),a=s.servers[0],c=r.serverUrl||(a?wk(a,r.serverVariables):"");let u=e;const f=[],h={...r.headers||{}},g=[];for(const E of s.parameters){const D=E.in==="header"?r.headers?.[E.name]:E.in==="cookie"?r.cookies?.[E.name]:r.parameters?.[E.name];if(!(D===void 0||D===""))if(E.in==="path")u=u.replace(`{${E.name}}`,Nk(E,D));else if(E.in==="query")for(const[O,j]of Tk(E,D))f.push(`${encodeURIComponent(O)}=${D0(j,E.allowReserved)}`);else E.in==="header"?h[E.name]=_0(D,E.explode):E.in==="cookie"&&g.push(`${E.name}=${encodeURIComponent(_0(D,E.explode))}`)}Ok(t,s.security,h,f,g,r.auth||{}),g.length&&(h.Cookie=g.join("; "));let b,v,w;if(r.body){const E=r.contentType||"application/json";if(b=r.body,E==="application/x-www-form-urlencoded"){const D=L0(r.body);b=D?Object.entries(D).flatMap(([O,j])=>Array.isArray(j)?j.map(R=>`${encodeURIComponent(O)}=${encodeURIComponent(cn(R))}`):[`${encodeURIComponent(O)}=${encodeURIComponent(cn(j))}`]).join("&"):r.body,w=b,v="form",h["Content-Type"]=E}else if(E.startsWith("multipart/form-data")){const D=L0(r.body);if(D&&typeof FormData<"u"){const O=new FormData;for(const[j,R]of Object.entries(D))Array.isArray(R)?R.forEach(_=>O.append(j,cn(_))):O.append(j,cn(R));w=O}else w=r.body;v="multipart"}else w=r.body,v=E.includes("json")?"json":"text",h["Content-Type"]=E}const A=f.join("&");return{url:`${c.replace(/\/$/,"")}${u}${A?`?${A}`:""}`,method:s.method,headers:h,body:b,bodyKind:v,init:{method:s.method,headers:h,body:w}}}function Rk(t,e,n){return Sk(t,e,n)}function q0(t,e,n){return Ck(t,e,n)}function B0(t,e,n,r={}){return Mk(t,e,n,r)}const un=t=>JSON.stringify(t);function Dk(t,e){const n=Object.entries(t.headers);if(e==="curl"){const a=[`curl -X ${t.method} ${un(t.url)}`];for(const[c,u]of n)a.push(` -H ${un(`${c}: ${u}`)}`);return t.body&&a.push(` --data-raw ${un(t.body)}`),a.join(` \\ `)}if(e==="javascript"){const a={method:t.method};return n.length&&(a.headers=t.headers),t.body&&(a.body=t.body),`const response = await fetch(${un(t.url)}, ${JSON.stringify(a,null,2)}); const data = await response.json();`}if(e==="python"){const a=["import requests","",`url = ${un(t.url)}`];return n.length&&a.push(`headers = ${JSON.stringify(t.headers,null,2)}`),t.body&&a.push(`body = ${un(t.body)}`),a.push(`response = requests.request(${un(t.method)}, url${n.length?", headers=headers":""}${t.body?", data=body":""})`,"print(response.text)"),a.join(` `)}if(e==="go"){const a=t.body?`strings.NewReader(${un(t.body)})`:"nil",c=["package main","","import (",' "fmt"',' "io"',' "net/http"'];t.body&&c.push(' "strings"'),c.push(")","","func main() {",` req, _ := http.NewRequest(${un(t.method)}, ${un(t.url)}, ${a})`);for(const[u,f]of n)c.push(` req.Header.Set(${un(u)}, ${un(f)})`);return c.push(" res, err := http.DefaultClient.Do(req)"," if err != nil { panic(err) }"," defer res.Body.Close()"," data, _ := io.ReadAll(res.Body)"," fmt.Println(string(data))","}"),c.join(` `)}const r=["import java.net.URI;","import java.net.http.*;","","var client = HttpClient.newHttpClient();","var builder = HttpRequest.newBuilder()",` .uri(URI.create(${un(t.url)}))`];for(const[a,c]of n)r.push(` .header(${un(a)}, ${un(c)})`);const s=t.body?`HttpRequest.BodyPublishers.ofString(${un(t.body)})`:"HttpRequest.BodyPublishers.noBody()";return r.push(` .method(${un(t.method)}, ${s});`,"var response = client.send(builder.build(), HttpResponse.BodyHandlers.ofString());","System.out.println(response.body());"),r.join(` -`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function E(j){return j instanceof f?new f(j.type,E(j.content),j.alias):Array.isArray(j)?j.map(E):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var E=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(E){var j=document.getElementsByTagName("script");for(var M in j)if(j[M].src==E)return j[M]}return null}},isActive:function(E,j,M){for(var _="no-"+j;E;){var q=E.classList;if(q.contains(j))return!0;if(q.contains(_))return!1;E=E.parentElement}return!!M}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(E,j){var M=u.util.clone(u.languages[E]);for(var _ in j)M[_]=j[_];return M},insertBefore:function(E,j,M,_){_=_||u.languages;var q=_[E],R={};for(var J in q)if(q.hasOwnProperty(J)){if(J==j)for(var U in M)M.hasOwnProperty(U)&&(R[U]=M[U]);M.hasOwnProperty(J)||(R[J]=q[J])}var B=_[E];return _[E]=R,u.languages.DFS(u.languages,function(K,W){W===B&&K!=E&&(this[K]=R)}),R},DFS:function E(j,M,_,q){q=q||{};var R=u.util.objId;for(var J in j)if(j.hasOwnProperty(J)){M.call(j,J,j[J],_||J);var U=j[J],B=u.util.type(U);B==="Object"&&!q[R(U)]?(q[R(U)]=!0,E(U,M,null,q)):B==="Array"&&!q[R(U)]&&(q[R(U)]=!0,E(U,M,J,q))}}},plugins:{},highlightAll:function(E,j){u.highlightAllUnder(document,E,j)},highlightAllUnder:function(E,j,M){var _={callback:M,container:E,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var q=0,R;R=_.elements[q++];)u.highlightElement(R,j===!0,_.callback)},highlightElement:function(E,j,M){var _=u.util.getLanguage(E),q=u.languages[_];u.util.setLanguage(E,_);var R=E.parentElement;R&&R.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(R,_);var J=E.textContent,U={element:E,language:_,grammar:q,code:J};function B(W){U.highlightedCode=W,u.hooks.run("before-insert",U),U.element.innerHTML=U.highlightedCode,u.hooks.run("after-highlight",U),u.hooks.run("complete",U),M&&M.call(U.element)}if(u.hooks.run("before-sanity-check",U),R=U.element.parentElement,R&&R.nodeName.toLowerCase()==="pre"&&!R.hasAttribute("tabindex")&&R.setAttribute("tabindex","0"),!U.code){u.hooks.run("complete",U),M&&M.call(U.element);return}if(u.hooks.run("before-highlight",U),!U.grammar){B(u.util.encode(U.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(W){B(W.data)},K.postMessage(JSON.stringify({language:U.language,code:U.code,immediateClose:!0}))}else B(u.highlight(U.code,U.grammar,U.language))},highlight:function(E,j,M){var _={code:E,grammar:j,language:M};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(E,j){var M=j.rest;if(M){for(var _ in M)j[_]=M[_];delete j.rest}var q=new b;return v(q,q.head,E),g(E,q,j,q.head,0),A(q)},hooks:{all:{},add:function(E,j){var M=u.hooks.all;M[E]=M[E]||[],M[E].push(j)},run:function(E,j){var M=u.hooks.all[E];if(!(!M||!M.length))for(var _=0,q;q=M[_++];)q(j)}},Token:f};r.Prism=u;function f(E,j,M,_){this.type=E,this.content=j,this.alias=M,this.length=(_||"").length|0}f.stringify=function E(j,M){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=E(B,M)}),_}var q={type:j.type,content:E(j.content,M),tag:"span",classes:["token",j.type],attributes:{},language:M},R=j.alias;R&&(Array.isArray(R)?Array.prototype.push.apply(q.classes,R):q.classes.push(R)),u.hooks.run("wrap",q);var J="";for(var U in q.attributes)J+=" "+U+'="'+(q.attributes[U]||"").replace(/"/g,""")+'"';return"<"+q.tag+' class="'+q.classes.join(" ")+'"'+J+">"+q.content+""};function h(E,j,M,_){E.lastIndex=j;var q=E.exec(M);if(q&&_&&q[1]){var R=q[1].length;q.index+=R,q[0]=q[0].slice(R)}return q}function g(E,j,M,_,q,R){for(var J in M)if(!(!M.hasOwnProperty(J)||!M[J])){var U=M[J];U=Array.isArray(U)?U:[U];for(var B=0;B=R.reach);ue+=oe.value.length,oe=oe.next){var ve=oe.value;if(j.length>E.length)return;if(!(ve instanceof f)){var T=1,z;if(me){if(z=h(Q,ue,E,ye),!z||z.index>=E.length)break;var _e=z.index,he=z.index+z[0].length,ne=ue;for(ne+=oe.value.length;_e>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,ue=ne,oe.value instanceof f)continue;for(var ke=oe;ke!==j.tail&&(neR.reach&&(R.reach=Ie);var ut=oe.prev;Pe&&(ut=v(j,ut,Pe),ue+=Pe.length),w(j,ut,T);var Rt=new f(J,W?u.tokenize($e,W):$e,fe,$e);if(oe=v(j,ut,Rt),Ke&&v(j,oe,Ke),T>1){var Ce={cause:J+","+B,reach:Ie};g(E,j,M,oe.prev,ue,Ce),R&&Ce.reach>R.reach&&(R.reach=Ce.reach)}}}}}}function b(){var E={value:null,prev:null,next:null},j={value:null,prev:E,next:null};E.next=j,this.head=E,this.tail=j,this.length=0}function v(E,j,M){var _=j.next,q={value:M,prev:j,next:_};return j.next=q,_.prev=q,E.length++,q}function w(E,j,M){for(var _=j.next,q=0;q]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const O=Number(v.has(C))-Number(v.has(A));if(O)return O}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((O,D)=>p.jsx(Dr,{...f,schema:O,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=M=>{Object.prototype.hasOwnProperty.call(a,M)?n[M]=a[M]:Object.prototype.hasOwnProperty.call(s,M)?n[M]=s[M]:Object.prototype.hasOwnProperty.call(r,M)?n[M]=r[M]:delete n[M]},v={get(M){return a[M]},has(M){return Object.prototype.hasOwnProperty.call(a,M)},set(M,_){const q=String(_);a[M]=q,n[M]=q,u.push({action:"set",key:M,value:q})},unset(M){delete a[M],b(M),u.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(a,R)?a[R]:_})}},w={get(M){return r[M]},has(M){return Object.prototype.hasOwnProperty.call(r,M)},set(M,_){const q=String(_);r[M]=q,b(M),c.push({action:"set",key:M,value:q})},unset(M){delete r[M],b(M),c.push({action:"unset",key:M})},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(r,R)?r[R]:_})}},A={get(M){return n[M]},has(M){return Object.prototype.hasOwnProperty.call(n,M)},set(M,_){n[M]=String(_)},unset(M){delete n[M]},replaceIn(M){return M.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,q)=>{const R=q.trim();return Object.prototype.hasOwnProperty.call(n,R)?n[R]:_})}},C={get raw(){return e.body||""},set raw(M){e.body=String(M),e.bodyMode="raw"}},O={get method(){return e.method},set method(M){e.method=String(M)},get url(){return e.url},set url(M){e.url=String(M)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,E={request:O,response:D,environment:v,collection:w,variables:A,expect:Vk,test(M,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const q=Promise.resolve().then(_).then(()=>{f.push({name:M,passed:!0})}).catch(R=>{f.push({name:M,passed:!1,error:R instanceof Error?R.message:String(R)})});g.push(q)}},j={log:(...M)=>h.push(M.map(tn).join(" ")),info:(...M)=>h.push(M.map(tn).join(" ")),warn:(...M)=>h.push(`WARN ${M.map(tn).join(" ")}`),error:(...M)=>h.push(`ERROR ${M.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { +`)}function _k(t){return{curl:"cURL",javascript:"JavaScript",python:"Python",go:"Go",java:"Java"}[t]}function Lk(t,e){return Dk(t,e)}function $0(t){return _k(t)}var sf={exports:{}},I0;function qk(){return I0||(I0=1,(function(t){var e=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};var n=(function(r){var s=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,a=0,c={},u={manual:r.Prism&&r.Prism.manual,disableWorkerMessageHandler:r.Prism&&r.Prism.disableWorkerMessageHandler,util:{encode:function O(j){return j instanceof f?new f(j.type,O(j.content),j.alias):Array.isArray(j)?j.map(O):j.replace(/&/g,"&").replace(/"u")return null;if(document.currentScript&&document.currentScript.tagName==="SCRIPT")return document.currentScript;try{throw new Error}catch(_){var O=(/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(_.stack)||[])[1];if(O){var j=document.getElementsByTagName("script");for(var R in j)if(j[R].src==O)return j[R]}return null}},isActive:function(O,j,R){for(var _="no-"+j;O;){var L=O.classList;if(L.contains(j))return!0;if(L.contains(_))return!1;O=O.parentElement}return!!R}},languages:{plain:c,plaintext:c,text:c,txt:c,extend:function(O,j){var R=u.util.clone(u.languages[O]);for(var _ in j)R[_]=j[_];return R},insertBefore:function(O,j,R,_){_=_||u.languages;var L=_[O],M={};for(var G in L)if(L.hasOwnProperty(G)){if(G==j)for(var Y in R)R.hasOwnProperty(Y)&&(M[Y]=R[Y]);R.hasOwnProperty(G)||(M[G]=L[G])}var B=_[O];return _[O]=M,u.languages.DFS(u.languages,function(K,ee){ee===B&&K!=O&&(this[K]=M)}),M},DFS:function O(j,R,_,L){L=L||{};var M=u.util.objId;for(var G in j)if(j.hasOwnProperty(G)){R.call(j,G,j[G],_||G);var Y=j[G],B=u.util.type(Y);B==="Object"&&!L[M(Y)]?(L[M(Y)]=!0,O(Y,R,null,L)):B==="Array"&&!L[M(Y)]&&(L[M(Y)]=!0,O(Y,R,G,L))}}},plugins:{},highlightAll:function(O,j){u.highlightAllUnder(document,O,j)},highlightAllUnder:function(O,j,R){var _={callback:R,container:O,selector:'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'};u.hooks.run("before-highlightall",_),_.elements=Array.prototype.slice.apply(_.container.querySelectorAll(_.selector)),u.hooks.run("before-all-elements-highlight",_);for(var L=0,M;M=_.elements[L++];)u.highlightElement(M,j===!0,_.callback)},highlightElement:function(O,j,R){var _=u.util.getLanguage(O),L=u.languages[_];u.util.setLanguage(O,_);var M=O.parentElement;M&&M.nodeName.toLowerCase()==="pre"&&u.util.setLanguage(M,_);var G=O.textContent,Y={element:O,language:_,grammar:L,code:G};function B(ee){Y.highlightedCode=ee,u.hooks.run("before-insert",Y),Y.element.innerHTML=Y.highlightedCode,u.hooks.run("after-highlight",Y),u.hooks.run("complete",Y),R&&R.call(Y.element)}if(u.hooks.run("before-sanity-check",Y),M=Y.element.parentElement,M&&M.nodeName.toLowerCase()==="pre"&&!M.hasAttribute("tabindex")&&M.setAttribute("tabindex","0"),!Y.code){u.hooks.run("complete",Y),R&&R.call(Y.element);return}if(u.hooks.run("before-highlight",Y),!Y.grammar){B(u.util.encode(Y.code));return}if(j&&r.Worker){var K=new Worker(u.filename);K.onmessage=function(ee){B(ee.data)},K.postMessage(JSON.stringify({language:Y.language,code:Y.code,immediateClose:!0}))}else B(u.highlight(Y.code,Y.grammar,Y.language))},highlight:function(O,j,R){var _={code:O,grammar:j,language:R};if(u.hooks.run("before-tokenize",_),!_.grammar)throw new Error('The language "'+_.language+'" has no grammar.');return _.tokens=u.tokenize(_.code,_.grammar),u.hooks.run("after-tokenize",_),f.stringify(u.util.encode(_.tokens),_.language)},tokenize:function(O,j){var R=j.rest;if(R){for(var _ in R)j[_]=R[_];delete j.rest}var L=new b;return v(L,L.head,O),g(O,L,j,L.head,0),A(L)},hooks:{all:{},add:function(O,j){var R=u.hooks.all;R[O]=R[O]||[],R[O].push(j)},run:function(O,j){var R=u.hooks.all[O];if(!(!R||!R.length))for(var _=0,L;L=R[_++];)L(j)}},Token:f};r.Prism=u;function f(O,j,R,_){this.type=O,this.content=j,this.alias=R,this.length=(_||"").length|0}f.stringify=function O(j,R){if(typeof j=="string")return j;if(Array.isArray(j)){var _="";return j.forEach(function(B){_+=O(B,R)}),_}var L={type:j.type,content:O(j.content,R),tag:"span",classes:["token",j.type],attributes:{},language:R},M=j.alias;M&&(Array.isArray(M)?Array.prototype.push.apply(L.classes,M):L.classes.push(M)),u.hooks.run("wrap",L);var G="";for(var Y in L.attributes)G+=" "+Y+'="'+(L.attributes[Y]||"").replace(/"/g,""")+'"';return"<"+L.tag+' class="'+L.classes.join(" ")+'"'+G+">"+L.content+""};function h(O,j,R,_){O.lastIndex=j;var L=O.exec(R);if(L&&_&&L[1]){var M=L[1].length;L.index+=M,L[0]=L[0].slice(M)}return L}function g(O,j,R,_,L,M){for(var G in R)if(!(!R.hasOwnProperty(G)||!R[G])){var Y=R[G];Y=Array.isArray(Y)?Y:[Y];for(var B=0;B=M.reach);he+=oe.value.length,oe=oe.next){var Se=oe.value;if(j.length>O.length)return;if(!(Se instanceof f)){var T=1,z;if(ce){if(z=h(J,he,O,be),!z||z.index>=O.length)break;var Re=z.index,me=z.index+z[0].length,ne=he;for(ne+=oe.value.length;Re>=ne;)oe=oe.next,ne+=oe.value.length;if(ne-=oe.value.length,he=ne,oe.value instanceof f)continue;for(var Ce=oe;Ce!==j.tail&&(neM.reach&&(M.reach=Be);var dt=oe.prev;He&&(dt=v(j,dt,He),he+=He.length),w(j,dt,T);var At=new f(G,ee?u.tokenize(qe,ee):qe,ge,qe);if(oe=v(j,dt,At),Je&&v(j,oe,Je),T>1){var yt={cause:G+","+B,reach:Be};g(O,j,R,oe.prev,he,yt),M&&yt.reach>M.reach&&(M.reach=yt.reach)}}}}}}function b(){var O={value:null,prev:null,next:null},j={value:null,prev:O,next:null};O.next=j,this.head=O,this.tail=j,this.length=0}function v(O,j,R){var _=j.next,L={value:R,prev:j,next:_};return j.next=L,_.prev=L,O.length++,L}function w(O,j,R){for(var _=j.next,L=0;L]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},Prism.languages.json={property:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,lookbehind:!0,greedy:!0},string:{pattern:/(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,lookbehind:!0,greedy:!0},comment:{pattern:/\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},number:/-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,punctuation:/[{}[\],]/,operator:/:/,boolean:/\b(?:false|true)\b/,null:{pattern:/\bnull\b/,alias:"keyword"}},Prism.languages.webmanifest=Prism.languages.json,(function(t){var e=/[*&][^\s[\]{},]+/,n=/!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/,r="(?:"+n.source+"(?:[ ]+"+e.source+")?|"+e.source+"(?:[ ]+"+n.source+")?)",s=/(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-])(?:[ \t]*(?:(?![#:])|:))*/.source.replace(//g,function(){return/[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source}),a=/"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;function c(u,f){f=(f||"").replace(/m/g,"")+"m";var h=/([:\-,[{]\s*(?:\s<>[ \t]+)?)(?:<>)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return u});return RegExp(h,f)}t.languages.yaml={scalar:{pattern:RegExp(/([\-:]\s*(?:\s<>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<>/g,function(){return r})),lookbehind:!0,alias:"string"},comment:/#.*/,key:{pattern:RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<>[ \t]+)?)<>(?=\s*:\s)/.source.replace(/<>/g,function(){return r}).replace(/<>/g,function(){return"(?:"+s+"|"+a+")"})),lookbehind:!0,greedy:!0,alias:"atrule"},directive:{pattern:/(^[ \t]*)%.+/m,lookbehind:!0,alias:"important"},datetime:{pattern:c(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),lookbehind:!0,alias:"number"},boolean:{pattern:c(/false|true/.source,"i"),lookbehind:!0,alias:"important"},null:{pattern:c(/null|~/.source,"i"),lookbehind:!0,alias:"important"},string:{pattern:c(a),lookbehind:!0,greedy:!0},number:{pattern:c(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source,"i"),lookbehind:!0},tag:n,important:e,punctuation:/---|[:[\]{}\-,|>?]|\.\.\./},t.languages.yml=t.languages.yaml})(Prism),Prism.languages.javascript=Prism.languages.extend("clike",{"class-name":[Prism.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+(/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source)+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),Prism.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:Prism.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:Prism.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:Prism.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),Prism.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),Prism.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),Prism.languages.markup&&(Prism.languages.markup.tag.addInlined("script","javascript"),Prism.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),Prism.languages.js=Prism.languages.javascript,(function(t){var e="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+e),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+e),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};t.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+e),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+e),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=t.languages.bash;for(var s=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],a=r.variable[1].inside,c=0;c]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},Prism.languages.python["string-interpolation"].inside.interpolation.inside.rest=Prism.languages.python,Prism.languages.py=Prism.languages.python),H0}Ik(),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];var U0={},V0;function Hk(){return V0||(V0=1,(function(t){var e=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};t.languages.java=t.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:e,function:[t.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),t.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),t.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:e,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,function(){return e.source})),lookbehind:!0,inside:{punctuation:/\./}}})})(Prism)),U0}Hk();const Rr=({code:t,language:e,title:n,showCopy:r=!0,theme:s="dark",wrap:a=!1})=>{const[c,u]=Sd.useState(!1),f=I.useRef(null);I.useEffect(()=>{f.current&&$k.highlightElement(f.current)},[t,e,s]);const h=async()=>{try{await navigator.clipboard.writeText(t),u(!0),setTimeout(()=>u(!1),2e3)}catch(A){console.error("Failed to copy text: ",A)}},g=s==="dark"?"bg-gray-900 border-gray-700":"bg-gray-50 border-gray-200",b=s==="dark"?"bg-gray-800 border-gray-700 text-gray-300":"bg-gray-100 border-gray-200 text-gray-700",v=s==="dark"?"text-gray-400 hover:text-gray-200":"text-gray-500 hover:text-gray-900",w={"--fd-code-muted":s==="dark"?"#9ca3af":"#64748b","--fd-code-string":s==="dark"?"#86efac":"#15803d","--fd-code-keyword":s==="dark"?"#c4b5fd":"#6d28d9","--fd-code-number":s==="dark"?"#fb923c":"#c2410c","--fd-code-accent":s==="dark"?"#93c5fd":"#1d4ed8"};return p.jsxs("div",{className:`flexdoc-code min-w-0 rounded-lg overflow-hidden border ${g}`,"data-code-theme":s,style:w,children:[(n||r)&&p.jsxs("div",{className:`flex items-center justify-between gap-3 px-3 sm:px-4 py-2 border-b ${b}`,children:[n&&p.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:n}),r&&p.jsx("button",{onClick:h,className:`shrink-0 flex items-center gap-1 text-xs transition-colors ${v}`,"aria-label":"Copy code to clipboard",children:c?p.jsxs(p.Fragment,{children:[p.jsx(qg,{className:"w-3 h-3"}),p.jsx("span",{children:"Copied"})]}):p.jsxs(p.Fragment,{children:[p.jsx(PA,{className:"w-3 h-3"}),p.jsx("span",{children:"Copy"})]})})]}),p.jsx("div",{className:`p-3 sm:p-4 overflow-x-auto ${s==="dark"?"bg-gray-800":"bg-white"}`,children:p.jsx("pre",{className:`m-0 text-xs sm:text-sm ${a?"whitespace-pre-wrap break-words":""} ${s==="dark"?"text-gray-100":"text-gray-800"}`,children:p.jsx("code",{ref:f,className:`language-${e} bg-transparent`,children:t})})})]})};function zk(t){const e=Array.isArray(t.type)?t.type.join(" | "):t.type;return e?t.format?`${e} (${t.format})`:e:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":t.const!==void 0?"const":"any"}const Dr=({spec:t,schema:e,theme:n,required:r=!1,level:s=0,seen:a=new Set,requiredPropsFirst:c=!1,sortPropsAlphabetically:u=!1})=>{const f={spec:t,theme:n,requiredPropsFirst:c,sortPropsAlphabetically:u};if(In.isReference(e)){if(a.has(e.$ref))return p.jsxs("div",{className:"py-1 text-sm opacity-70",children:["↳ ",p.jsx("code",{children:e.$ref.replace("#/components/schemas/","")})," (recursive reference)"]});const A=new Set(a);A.add(e.$ref);let C;try{C=In.resolveReference(t,e.$ref)}catch{return p.jsxs("div",{className:"py-1 text-sm text-red-500",children:["Unresolved reference: ",p.jsx("code",{children:e.$ref})]})}return p.jsx(Dr,{...f,schema:C,required:r,level:s,seen:A})}const h=n==="dark"?"text-gray-400":"text-gray-600",g=n==="dark"?"border-gray-700":"border-gray-200",b=[["All of",e.allOf],["One of",e.oneOf],["Any of",e.anyOf]],v=new Set(e.required||[]),w=Object.entries(e.properties||{}).sort(([A],[C])=>{if(c){const E=Number(v.has(C))-Number(v.has(A));if(E)return E}return u?A.localeCompare(C):0});return p.jsxs("div",{className:s?`border-l-2 ${g} pl-3`:"",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 py-1",children:[p.jsx("span",{className:n==="dark"?"text-blue-300":"text-blue-600",children:zk(e)}),r&&p.jsx("span",{className:"rounded bg-red-100 px-2 py-0.5 text-xs text-red-700 dark:bg-red-900/30 dark:text-red-300",children:"required"}),(e.nullable||Array.isArray(e.type)&&e.type.includes("null"))&&p.jsx("span",{className:"rounded bg-gray-100 px-2 py-0.5 text-xs text-gray-700 dark:bg-gray-700 dark:text-gray-300",children:"nullable"}),e.deprecated&&p.jsx("span",{className:"rounded bg-orange-100 px-2 py-0.5 text-xs text-orange-700",children:"deprecated"}),e.readOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"readOnly"}),e.writeOnly&&p.jsx("span",{className:"text-xs opacity-60",children:"writeOnly"})]}),e.description&&p.jsx("p",{className:`mt-1 text-sm leading-relaxed ${h}`,children:e.description}),e.enum&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Allowed: ",e.enum.map(String).join(", ")]}),e.const!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Constant: ",JSON.stringify(e.const)]}),e.default!==void 0&&p.jsxs("p",{className:`mt-1 text-xs ${h}`,children:["Default: ",JSON.stringify(e.default)]}),(e.example!==void 0||e.examples?.length)&&p.jsx("div",{className:"mt-2",children:p.jsx(Rr,{code:JSON.stringify(e.example??e.examples?.[0],null,2),language:"json",title:"Example",showCopy:!1,theme:n,wrap:!0})}),e.items&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Items"}),p.jsx(Dr,{...f,schema:e.items,level:s+1,seen:a})]}),b.map(([A,C])=>C?.length?p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-2 text-xs font-semibold uppercase tracking-wide opacity-60",children:A}),p.jsx("div",{className:"space-y-3",children:C.map((E,D)=>p.jsx(Dr,{...f,schema:E,level:s+1,seen:a},D))})]},A):null),w.length>0&&p.jsx("div",{className:"mt-3 space-y-3",children:w.map(([A,C])=>p.jsxs("div",{children:[p.jsx("div",{className:"font-mono text-sm font-medium",children:A}),p.jsx(Dr,{...f,schema:C,required:v.has(A),level:s+1,seen:a})]},A))}),e.additionalProperties&&typeof e.additionalProperties=="object"&&p.jsxs("div",{className:"mt-3",children:[p.jsx("div",{className:"mb-1 text-xs font-semibold uppercase tracking-wide opacity-60",children:"Additional properties"}),p.jsx(Dr,{...f,schema:e.additionalProperties,level:s+1,seen:a})]})]})};function Sn(t){return{preRequest:t?.preRequest||"",tests:t?.tests||""}}function Uk(t){return{...t,query:t.query?.map(e=>({...e})),headers:t.headers?.map(e=>({...e})),urlencoded:t.urlencoded?.map(e=>({...e})),formData:t.formData?.map(e=>({...e})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:t.auth?{...t.auth}:void 0}}function Bo(t){return Object.assign(Object.create(null),t)}function tn(t){if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function el(t,e){if(Object.is(t,e))return!0;if(typeof t!=typeof e||t===null||e===null)return!1;if(Array.isArray(t))return Array.isArray(e)&&t.length===e.length&&t.every((n,r)=>el(n,e[r]));if(typeof t=="object"&&typeof e=="object"){const n=t,r=e,s=Object.keys(n),a=Object.keys(r);return s.length===a.length&&s.every(c=>Object.prototype.hasOwnProperty.call(r,c)&&el(n[c],r[c]))}return!1}function hi(t){throw new Error(t)}function Vk(t){const e=h=>{Object.is(t,h)||hi(`expected ${tn(t)} to equal ${tn(h)}`)},n=h=>{el(t,h)||hi(`expected ${tn(t)} to deeply equal ${tn(h)}`)},r=h=>{(typeof t=="string"?t.includes(String(h)):Array.isArray(t)&&t.some(b=>el(b,h)))||hi(`expected ${tn(t)} to include ${tn(h)}`)},s=(h,...g)=>{(!t||typeof t!="object"||!Object.prototype.hasOwnProperty.call(t,h))&&hi(`expected value to have property ${h}`),g.length>0&&!el(t[h],g[0])&&hi(`expected property ${h} to equal ${tn(g[0])}`)},f={above:h=>{(typeof t!="number"||t<=h)&&hi(`expected ${tn(t)} to be above ${h}`)},below:h=>{(typeof t!="number"||t>=h)&&hi(`expected ${tn(t)} to be below ${h}`)},oneOf:h=>{h.some(g=>el(t,g))||hi(`expected ${tn(t)} to be one of ${tn(h)}`)}};return Object.defineProperties(f,{ok:{get:()=>(t||hi(`expected ${tn(t)} to be truthy`),!0)},true:{get:()=>(t!==!0&&hi(`expected ${tn(t)} to be true`),!0)},false:{get:()=>(t!==!1&&hi(`expected ${tn(t)} to be false`),!0)}}),{to:{equal:e,eql:n,include:r,match:h=>{(typeof t!="string"||!h.test(t))&&hi(`expected ${tn(t)} to match ${h}`)},have:{property:s},be:f}}}function lf(t,e){return t.findIndex(n=>n.key.toLowerCase()===e.toLowerCase())}function Fk(t){const e=()=>t.headers||(t.headers=[]),n=(r,s)=>{const a=e(),c=lf(a,r),u={key:r,value:String(s),enabled:!0};c>=0?a[c]=u:a.push(u)};return{get(r){const s=lf(e(),r);return s>=0?e()[s].value:void 0},has(r){return lf(e(),r)>=0},set:n,upsert({key:r,value:s}){n(r,s)},remove(r){t.headers=e().filter(s=>s.key.toLowerCase()!==r.toLowerCase())},toObject(){const r={};for(const s of e())s.enabled!==!1&&(r[s.key]=s.value);return r}}}function Pk(t){return{get(e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]},has(e){return t.some(([n])=>n.toLowerCase()===e.toLowerCase())},toObject(){const e={};for(const[n,r]of t)e[n]=r;return e}}}async function F0(t){const e=Uk(t.draft),n=Bo(t.variables||{}),r=Bo(t.collectionVariables||{}),s=Bo(t.externalVariables||{}),a=Bo(t.environmentVariables||{}),c=[],u=[],f=[],h=[],g=[],b=R=>{Object.prototype.hasOwnProperty.call(a,R)?n[R]=a[R]:Object.prototype.hasOwnProperty.call(s,R)?n[R]=s[R]:Object.prototype.hasOwnProperty.call(r,R)?n[R]=r[R]:delete n[R]},v={get(R){return a[R]},has(R){return Object.prototype.hasOwnProperty.call(a,R)},set(R,_){const L=String(_);a[R]=L,n[R]=L,u.push({action:"set",key:R,value:L})},unset(R){delete a[R],b(R),u.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(a,M)?a[M]:_})}},w={get(R){return r[R]},has(R){return Object.prototype.hasOwnProperty.call(r,R)},set(R,_){const L=String(_);r[R]=L,b(R),c.push({action:"set",key:R,value:L})},unset(R){delete r[R],b(R),c.push({action:"unset",key:R})},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(r,M)?r[M]:_})}},A={get(R){return n[R]},has(R){return Object.prototype.hasOwnProperty.call(n,R)},set(R,_){n[R]=String(_)},unset(R){delete n[R]},replaceIn(R){return R.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(_,L)=>{const M=L.trim();return Object.prototype.hasOwnProperty.call(n,M)?n[M]:_})}},C={get raw(){return e.body||""},set raw(R){e.body=String(R),e.bodyMode="raw"}},E={get method(){return e.method},set method(R){e.method=String(R)},get url(){return e.url},set url(R){e.url=String(R)},headers:Fk(e),body:C},D=t.response?{code:t.response.status,status:t.response.statusText,responseTime:t.response.responseTime,headers:Pk(t.response.headers),text:()=>t.response?.body||"",json:()=>JSON.parse(t.response?.body||"")}:void 0,O={request:E,response:D,environment:v,collection:w,variables:A,expect:Vk,test(R,_){if(t.phase!=="tests")throw new Error("flex.test is only available in post-response test scripts.");const L=Promise.resolve().then(_).then(()=>{f.push({name:R,passed:!0})}).catch(M=>{f.push({name:R,passed:!1,error:M instanceof Error?M.message:String(M)})});g.push(L)}},j={log:(...R)=>h.push(R.map(tn).join(" ")),info:(...R)=>h.push(R.map(tn).join(" ")),warn:(...R)=>h.push(`WARN ${R.map(tn).join(" ")}`),error:(...R)=>h.push(`ERROR ${R.map(tn).join(" ")}`)};try{return await new Function("flex","console",`"use strict"; return (async () => { ${t.script} -})();`)(E,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(M){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:M instanceof Error?M.message:String(M)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Ye(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Ye(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Ye(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Ye(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Ye(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Ye(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Ye(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Ye(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Ye(r,e)||"")),t.username!==void 0&&(n.username=Ye(t.username,e)),t.password!==void 0&&(n.password=Ye(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Ye(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Ye(t.key,e)||"",value:Ye(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Ye(t.username,e)||"",password:Ye(t.password,e)||""}:t.type==="hawk"?{...t,id:Ye(t.id,e)||"",key:Ye(t.key,e)||"",ext:Ye(t.ext,e)}:t.type==="ntlm"?{...t,username:Ye(t.username,e)||"",password:Ye(t.password,e)||"",domain:Ye(t.domain,e),workstation:Ye(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Ye(t.consumerKey,e)||"",consumerSecret:Ye(t.consumerSecret,e)||"",token:Ye(t.token,e),tokenSecret:Ye(t.tokenSecret,e),realm:Ye(t.realm,e)}:{...t,accessKey:Ye(t.accessKey,e)||"",secretKey:Ye(t.secretKey,e)||"",sessionToken:Ye(t.sessionToken,e),region:Ye(t.region,e)||"",service:Ye(t.service,e)||""}}function K0(t,e){return{method:Ye(t.method,e)??t.method,url:Ye(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),body:Ye(t.body,e),contentType:Ye(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Ye(n.key,e)||"",value:Ye(n.value,e)||"",fileName:Ye(n.fileName,e),contentType:Ye(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Ye(t.binary.fileName,e),contentType:Ye(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Ye(t.graphql.query,e)||"",variables:Ye(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let O=u.length-1;O>=0;O-=1)u[O][0].toLowerCase()==="content-type"&&u.splice(O,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:E})=>`${encodeURIComponent(D)}=${encodeURIComponent(E)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const O=new FormData,D=[];for(const E of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(E.type==="file"){if(!E.file)throw new Error(`File field "${E.key}" needs a file selection.`);O.append(E.key,E.file,E.fileName||E.file.name),D.push(`${E.key}=[file: ${E.fileName||E.file.name}]`)}else O.append(E.key,E.value),D.push(`${E.key}=${E.value}`);f=D.join(` -`),g=O,h="multipart"}else if(b==="binary"){const O=n.binary;if(!O?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${O.fileName||O.file.name}]`,g=O.file,A||u.push(["Content-Type",C||O.contentType||O.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const O=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let E={};if(D)try{E=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:O,variables:E}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const O=b==="json"?"application/json":void 0;!A&&(C||O)&&u.push(["Content-Type",C||O]),h=b==="json"||(A||C||O)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Je(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Je(t,"key")||!Je(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Je(t,"token");if(t.type==="oauth2"){if(!Je(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Je(t,"username")&&Je(t,"password"):t.type==="apiKey"?Je(t,"key")&&Je(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Je(t,"id")&&Je(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Je(t,"username")&&Je(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Je(t,"consumerKey")&&Je(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Je(t,"accessKey")&&Je(t,"secretKey")&&Je(t,"region")&&Je(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Je(t,"method")||!Je(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Je(t.graphql,"query")||!Je(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Je(t,"id")&&Je(t,"key")&&Je(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Je(t,"name")||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Je(t,"preRequest")||!Je(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Je(t,"id")||!Je(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Je(t,"name")||!ny(t.request)||!Je(t,"createdAt")||!Je(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Je(t,"id")||!Je(t,"name")||!Array.isArray(t.variables)||!Je(t,"createdAt")||!Je(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Je(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Je(t,"id")||!ny(t.request)||!Je(t,"executedMethod")||!Je(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Je(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,E)=>{if(typeof E!="number"||!Number.isFinite(E))return;const j=Math.max(0,E);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const E=[...D.retained].sort((j,M)=>j-M);return{sampleCount:E.length,sampled:D.observed>E.length,minMs:E[0],p50Ms:pf(E,.5),p95Ms:pf(E,.95),p99Ms:pf(E,.99),maxMs:E[E.length-1]}};return{record:D=>{const E=n();s===null&&(s=E),a=E,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const R=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[R]=(u[R]??0)+1;return}const M=f[j];M.attempts+=1;const _=D.response;if(!_){M.failures+=1,D.failureKind==="browser-network"&&(M.networkFailures+=1);return}if(M.responses+=1,M.statusClasses[HC(_.status)]+=1,j==="browser"){v(M.total,_.responseTime);return}const q=_.hostRoundTripTime??_.responseTime;v(M.total,q),v(M.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(M.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,E)=>{const j=f[E];return D[E]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ -`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,O=!1,D,E;try{if(n.preRequest.trim()){const R=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=R.draft,c=R.variables,u=R.collectionVariables,h=R.environmentVariables,g=[...g,...R.logs],R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${R.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,M]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||M.length>0){const fe=yy(M,t.hostExecution);return{error:fe,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:fe,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const R=await iN(a);C=s(),O=!0,D="api-host";const J=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:R.headers,body:R.body,...t.signal?{signal:t.signal}:{}}),U=await J.text(),B=s()-C;let K;try{const fe=U?JSON.parse(U):{};if(!fe||typeof fe!="object"||Array.isArray(fe))throw new Error("invalid");K=fe}catch{throw new Error("API host returned an invalid execution response.")}const W=typeof K.error=="string"?K.error:void 0;if(!J.ok)throw new Error(W||`API host execution failed with HTTP ${J.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const ye=K.headers.map(fe=>Array.isArray(fe)?[String(fe[0]),String(fe[1])]:["",""]).filter(([fe])=>!!fe),me=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:ye,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...me?{cookies:me}:{}}}else{const R=G0(a);w=R.method,A=R.url,t.onRequestBuilt?.(R);let J={...R.init,url:R.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(J=await t.requestInterceptor(J)),t.signal&&(J.signal=t.signal);const{url:U,...B}=J;if(A=U,E=JC(U,B),C=s(),O=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(U,B),W=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:W,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const R=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...R.logs],b=R.tests.map(J=>({...J})),R.collectionChanges.length>0&&t.onCollectionChanges?.(R.collectionChanges),R.environmentChanges.length>0&&t.onEnvironmentChanges?.(R.environmentChanges),R.error&&(v=`Test script: ${R.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([R,J])=>[R,J]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...E?{curlCommand:E}:{},...v?{scriptError:v}:{}}}catch(j){const M=GC(j),_={error:M,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return O&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:M,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class gt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?gt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends gt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends gt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` -`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}gt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` -`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(gt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?gt.of(w.split(r||wf)):w:gt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?gt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?gt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return Ae.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return Ae.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return Ae.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class Ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:Ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new Ae(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new Ae([Ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?Ae.range(f,u):Ae.range(u,f))}}return new Ae(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(O=>O instanceof Ue?v.facet(O)===b.facet(O):O instanceof qr?v.field(O,!1)==b.field(O,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(O=>O.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let O=A.combine(w.map(D=>D.value));f.push(r&&A.compare(O,r.facet(A))?r.facet(A):O)}else{for(let O of w)O.type==0?(u[O.id]=f.length<<1|1,f.push(O.value)):(u[O.id]=h.length<<1,h.push(D=>O.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(O=>NN(O,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class wt{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new wt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new wt(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:Ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return wt.create({doc:e.doc,selection:Ae.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof gt?e.doc:gt.of((e.doc||"").split(n.staticFacet(wt.lineSeparator)||wf)),s=e.selection?e.selection instanceof Ae?e.selection:Ae.single(e.selection.anchor,e.selection.head):Ae.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new wt(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(wt.tabSize)}get lineBreak(){return this.facet(wt.lineSeparator)||` -`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(wt.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),wt.lineSeparator=By,wt.readOnly=zy,wt.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),wt.languageData=qy,wt.changeFilter=$y,wt.transactionFilter=Iy,wt.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aO||C==O&&v.startSide>0&&v.endSide<=0)continue;if(!((O-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,O-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(O-h),r=O,s=v.endSide;else{if(C==O)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,O-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,O,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class mt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new mt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?mt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return mt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=mt.empty;s=s.nextLayer)n=new mt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}mt.empty=new mt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}mt.empty.nextLayer=mt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(mt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=mt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(O=>C.replace(/&/,O))).reduce((C,O)=>C.concat(O)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` +})();`)(O,j),await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h}}catch(R){return await Promise.all(g),{draft:e,variables:n,collectionVariables:r,externalVariables:s,environmentVariables:a,collectionChanges:c,environmentChanges:u,tests:f,logs:h,error:R instanceof Error?R.message:String(R)}}}function af(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()!=="")}function P0(t){if(t.bodyMode)return t.bodyMode;if(t.binary?.file||t.binary?.fileName)return"binary";if(t.formData?.length)return"formdata";if(t.urlencoded?.length)return"urlencoded";if(t.graphql&&(t.graphql.query||t.graphql.variables))return"graphql";if(!t.body)return"none";const e=(t.contentType||"").toLowerCase();return e.includes("application/x-www-form-urlencoded")?"urlencoded":e.includes("multipart/form-data")?"formdata":e.includes("json")?"json":"raw"}function Y0(t){const e=new Set,n=t.auth;return n?.type==="apiKey"&&n.in==="cookie"?e.add("cookies"):n?.type==="digest"?e.add("digest"):n?.type==="hawk"?e.add("hawk"):n?.type==="ntlm"?e.add("ntlm"):n?.type==="oauth1"?e.add("oauth1"):n?.type==="awsv4"&&e.add("awsv4"),t.headers?.some(r=>r.enabled!==!1&&r.key.trim().toLowerCase()==="cookie")&&e.add("cookies"),t.hostExecution?.cookieJar==="session"&&e.add("cookies"),t.hostExecution?.certificateId&&e.add("clientCertificates"),[...e]}function Yk(t,e){if(!e.length)return t;const n=t.indexOf("#"),r=n>=0?t.slice(0,n):t,s=n>=0?t.slice(n):"",a=e.map(({key:u,value:f})=>`${encodeURIComponent(u)}=${encodeURIComponent(f)}`).join("&"),c=r.includes("?")?r.endsWith("?")||r.endsWith("&")?"":"&":"?";return`${r}${c}${a}${s}`}function Kk(t){const e=t.indexOf("#"),n=e>=0?t.slice(0,e):t,r=e>=0?t.slice(e):"",s=n.indexOf("?");if(s<0)return{url:t,query:[]};const a=[];return new URLSearchParams(n.slice(s+1)).forEach((u,f)=>a.push({key:f,value:u})),{url:`${n.slice(0,s)}${r}`,query:a}}function of(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]}function $o(t,e,n){for(let r=t.length-1;r>=0;r-=1)t[r][0].toLowerCase()===e.toLowerCase()&&t.splice(r,1);t.push([e,n])}function Gk(t){const e={};for(const[n,r]of t)e[n]=r;return e}function Xk(t){const e=t.headerEntries;if(!Array.isArray(e))return Object.entries(t.headers||{});const n=[];for(const r of e){if(Array.isArray(r)&&r.length>=2){n.push([String(r[0]),String(r[1])]);continue}if(r&&typeof r=="object"&&"key"in r&&"value"in r){const s=r;s.enabled!==!1&&n.push([String(s.key),String(s.value)])}}return n.length||e.length===0?n:Object.entries(t.headers||{})}function Jk(t){if(typeof globalThis.btoa=="function"){if(typeof TextEncoder>"u")throw new Error("Basic auth requires UTF-8 encoding support.");const n=new TextEncoder().encode(t);let r="";for(const s of n)r+=String.fromCharCode(s);return globalThis.btoa(r)}const e=globalThis.Buffer;if(e?.from)return e.from(t,"utf8").toString("base64");throw new Error("Basic auth requires a Base64 encoder in this runtime.")}function Pe(t,e){return t===void 0||t===""?t:t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(n,r)=>{const s=r.trim();return Object.prototype.hasOwnProperty.call(e,s)?e[s]:n})}function Qk(t,e){if(!t||t.type==="none"||t.type==="inherit")return t;if(t.type==="bearer")return{type:"bearer",token:Pe(t.token,e)||""};if(t.type==="oauth2"){const n={...t,accessToken:Pe(t.accessToken,e)||""};return t.authorizationUrl!==void 0&&(n.authorizationUrl=Pe(t.authorizationUrl,e)),t.tokenUrl!==void 0&&(n.tokenUrl=Pe(t.tokenUrl,e)),t.clientId!==void 0&&(n.clientId=Pe(t.clientId,e)),t.clientSecret!==void 0&&(n.clientSecret=Pe(t.clientSecret,e)),t.redirectUri!==void 0&&(n.redirectUri=Pe(t.redirectUri,e)),t.scopes!==void 0&&(n.scopes=t.scopes.map(r=>Pe(r,e)||"")),t.username!==void 0&&(n.username=Pe(t.username,e)),t.password!==void 0&&(n.password=Pe(t.password,e)),t.refreshToken!==void 0&&(n.refreshToken=Pe(t.refreshToken,e)),n}return t.type==="basic"?{type:"basic",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="apiKey"?{type:"apiKey",key:Pe(t.key,e)||"",value:Pe(t.value,e)||"",in:t.in}:t.type==="digest"?{type:"digest",username:Pe(t.username,e)||"",password:Pe(t.password,e)||""}:t.type==="hawk"?{...t,id:Pe(t.id,e)||"",key:Pe(t.key,e)||"",ext:Pe(t.ext,e)}:t.type==="ntlm"?{...t,username:Pe(t.username,e)||"",password:Pe(t.password,e)||"",domain:Pe(t.domain,e),workstation:Pe(t.workstation,e)}:t.type==="oauth1"?{...t,consumerKey:Pe(t.consumerKey,e)||"",consumerSecret:Pe(t.consumerSecret,e)||"",token:Pe(t.token,e),tokenSecret:Pe(t.tokenSecret,e),realm:Pe(t.realm,e)}:{...t,accessKey:Pe(t.accessKey,e)||"",secretKey:Pe(t.secretKey,e)||"",sessionToken:Pe(t.sessionToken,e),region:Pe(t.region,e)||"",service:Pe(t.service,e)||""}}function K0(t,e){return{method:Pe(t.method,e)??t.method,url:Pe(t.url,e)??t.url,query:t.query?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),headers:t.headers?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),body:Pe(t.body,e),contentType:Pe(t.contentType,e),bodyMode:t.bodyMode,urlencoded:t.urlencoded?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||""})),formData:t.formData?.map(n=>({...n,key:Pe(n.key,e)||"",value:Pe(n.value,e)||"",fileName:Pe(n.fileName,e),contentType:Pe(n.contentType,e)})),binary:t.binary?{...t.binary,fileName:Pe(t.binary.fileName,e),contentType:Pe(t.binary.contentType,e)}:void 0,graphql:t.graphql?{query:Pe(t.graphql.query,e)||"",variables:Pe(t.graphql.variables,e)||""}:void 0,auth:Qk(t.auth,e),hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function Wk(t,e,n){const r=t.auth;if(!(!r||r.type==="none"||r.type==="inherit")){if(r.type==="bearer"){r.token&&$o(e,"Authorization",`Bearer ${r.token}`);return}if(r.type==="oauth2"){r.accessToken&&$o(e,"Authorization",`Bearer ${r.accessToken}`);return}if(r.type==="basic"){(r.username||r.password)&&$o(e,"Authorization",`Basic ${Jk(`${r.username}:${r.password}`)}`);return}r.type!=="apiKey"||!r.key||(r.in==="query"?n.push({key:r.key,value:r.value}):r.in==="header"&&$o(e,r.key,r.value))}}function Zk(t,e={}){const n=e.variables?K0(t,e.variables):t,r=(n.method||"GET").trim().toUpperCase(),s=n.url.trim();if(!s)throw new Error("Request URL is required.");const a=Y0(n);if(a.length>0)throw new Error(`This request requires API host execution (${a.join(", ")}).`);const c=af(n.query),u=af(n.headers).map(({key:A,value:C})=>[A,C]);Wk(n,u,c);let f,h,g;const b=P0(n);if(b!=="none"){if(b==="formdata")for(let E=u.length-1;E>=0;E-=1)u[E][0].toLowerCase()==="content-type"&&u.splice(E,1);const A=of(u,"Content-Type"),C=n.contentType?.trim();if(b==="urlencoded")f=af(n.urlencoded).map(({key:D,value:O})=>`${encodeURIComponent(D)}=${encodeURIComponent(O)}`).join("&"),g=f,A||u.push(["Content-Type",C||"application/x-www-form-urlencoded"]),h="form";else if(b==="formdata"){const E=new FormData,D=[];for(const O of(n.formData||[]).filter(j=>j.enabled!==!1&&j.key.trim()!==""))if(O.type==="file"){if(!O.file)throw new Error(`File field "${O.key}" needs a file selection.`);E.append(O.key,O.file,O.fileName||O.file.name),D.push(`${O.key}=[file: ${O.fileName||O.file.name}]`)}else E.append(O.key,O.value),D.push(`${O.key}=${O.value}`);f=D.join(` +`),g=E,h="multipart"}else if(b==="binary"){const E=n.binary;if(!E?.file)throw new Error("Binary body needs a file selection.");f=`[file: ${E.fileName||E.file.name}]`,g=E.file,A||u.push(["Content-Type",C||E.contentType||E.file.type||"application/octet-stream"]),h="binary"}else if(b==="graphql"){const E=n.graphql?.query||"",D=n.graphql?.variables?.trim()||"";let O={};if(D)try{O=JSON.parse(D)}catch{throw new Error("GraphQL variables must be valid JSON.")}f=JSON.stringify({query:E,variables:O}),g=f,A||u.push(["Content-Type",C||"application/json"]),h="json"}else{f=n.body||"",g=f;const E=b==="json"?"application/json":void 0;!A&&(C||E)&&u.push(["Content-Type",C||E]),h=b==="json"||(A||C||E)?.includes("json")?"json":"text"}}const v=Gk(u);return{url:Yk(s,c),method:r,headers:v,headerEntries:u,body:f,bodyKind:h,init:{method:r,headers:u,body:g}}}function eC(t){const e=Xk(t),n=Kk(t.url),r=t.bodyKind==="binary"&&typeof File<"u"&&t.init.body instanceof File?t.init.body:void 0;return{method:t.method,url:n.url,query:n.query,headers:e.map(([s,a])=>({key:s,value:a})),body:t.body,contentType:of(e,"Content-Type"),bodyMode:t.bodyKind==="json"?"json":t.bodyKind==="form"?"urlencoded":t.bodyKind==="multipart"?"formdata":t.bodyKind==="binary"?"binary":t.body?"raw":"none",binary:t.bodyKind==="binary"?{file:r,fileName:r?.name,contentType:of(e,"Content-Type")}:void 0,urlencoded:t.bodyKind==="form"&&t.body?[...new URLSearchParams(t.body).entries()].map(([s,a])=>({key:s,value:a,enabled:!0})):void 0,auth:{type:"none"}}}function G0(t,e={}){return Zk(t,e)}function ha(t){return P0(t)}function tC(t){return Y0(t)}function nC(t,e){return K0(t,e)}function iC(t){return eC(t)}function rC(t,e,n){return t.paths[e]?.[n.toLowerCase()]}function sC(t,e){const n=t.components?.securitySchemes?.[e];if(!n)return;if(!("$ref"in n))return n;const r=n.$ref,s="#/components/securitySchemes/";if(!r.startsWith(s))return;const a=t.components?.securitySchemes?.[decodeURIComponent(r.slice(s.length))];return a&&!("$ref"in a)?a:void 0}function lC(t,e,n,r){const a=rC(t,e,n)?.security??t.security??[];if(!a.length)return;const c=a.find(f=>{const h=Object.keys(f);return h.length===1&&!!r[h[0]]});if(c)return c;const u=a.find(f=>{const h=Object.keys(f);return h.length>0&&h.every(g=>!!r[g])});return u||(a.find(f=>Object.keys(f).length===0)??a[0])}function aC(t,e,n=[]){if(e){if(t.type==="http"&&t.scheme?.toLowerCase()==="bearer")return{type:"bearer",token:e};if(t.type==="http"&&t.scheme?.toLowerCase()==="basic"){const r=e.indexOf(":");return r>=0?{type:"basic",username:e.slice(0,r),password:e.slice(r+1)}:{type:"basic",username:e,password:""}}if(t.type==="apiKey"&&(t.in==="header"||t.in==="query")&&t.name)return{type:"apiKey",key:t.name,value:e,in:t.in};if(t.type==="openIdConnect")return{type:"oauth2",accessToken:e,grantType:"accessToken",scopes:n};if(t.type==="oauth2"){const r=t.flows,s=r?.authorizationCode?["authorizationCode",r.authorizationCode]:r?.clientCredentials?["clientCredentials",r.clientCredentials]:r?.password?["password",r.password]:r?.implicit?["implicit",r.implicit]:void 0,a=s?.[1];return{type:"oauth2",accessToken:e,grantType:s?.[0]||"accessToken",authorizationUrl:a?.authorizationUrl,tokenUrl:a?.tokenUrl,scopes:n.length?n:Object.keys(a?.scopes||{})}}}}function X0(t,e){return{...t,headers:t.headers?.filter(n=>n.key.toLowerCase()!==e.toLowerCase())}}function oC(t,e){return{...t,query:t.query?.filter(n=>n.key!==e)}}function cC(t,e,n,r,s){let a=iC(s);const c=lC(t,e,n,r.auth||{});if(!c||Object.keys(c).length!==1)return a;const u=Object.keys(c)[0],f=sC(t,u),h=r.auth?.[u]||"";if(!f)return a;if(!h)return{...a,auth:{type:"inherit"}};const g=aC(f,h,c[u]||[]);return g?(g.type==="bearer"||g.type==="oauth2"||g.type==="basic"?a=X0(a,"Authorization"):g.type==="apiKey"&&g.in==="header"?a=X0(a,g.key):g.type==="apiKey"&&g.in==="query"&&(a=oC(a,g.key)),{...a,auth:g}):a}function uC(t,e,n,r,s){const a=B0(t,e,n,r);return{request:cC(t,e,n,r,a),serverUrl:r.serverUrl||s}}function Io(t){if(t)return t.type==="bearer"?{...t,token:""}:t.type==="oauth2"?{...t,accessToken:"",...t.clientSecret!==void 0?{clientSecret:""}:{},...t.password!==void 0?{password:""}:{},...t.refreshToken!==void 0?{refreshToken:""}:{},scopes:t.scopes?[...t.scopes]:void 0}:t.type==="basic"||t.type==="digest"||t.type==="ntlm"?{...t,password:""}:t.type==="apiKey"?{...t,value:""}:t.type==="hawk"?{...t,key:""}:t.type==="oauth1"?{...t,consumerSecret:"",...t.token!==void 0?{token:""}:{},...t.tokenSecret!==void 0?{tokenSecret:""}:{}}:t.type==="awsv4"?{...t,secretKey:"",...t.sessionToken!==void 0?{sessionToken:""}:{}}:{...t}}const cf="[REDACTED]";function dC(t){return t.trim().toLowerCase().replace(/[^a-z0-9]/g,"")}function uf(t){const e=dC(t);return e.includes("authorization")||e.includes("cookie")||e.includes("token")||e.includes("signature")||e.includes("secret")||e.includes("password")||e.endsWith("key")}function J0(t){return t?.map(e=>uf(e.key)?{...e,value:cf}:e)}function fC(t){return t?.map(e=>uf(e[0])?[e[0],cf]:e)}function Q0(t){const e=t.indexOf("#"),n=e>=0?t.slice(e):"",r=e>=0?t.slice(0,e):t,s=r.indexOf("?");if(s<0)return t;const a=r.slice(0,s),c=r.slice(s+1).split("&").map(u=>{if(!u)return u;const f=u.indexOf("="),h=f>=0?u.slice(0,f):u;let g=h;try{g=decodeURIComponent(h.replace(/\+/g," "))}catch{}return uf(g)?`${h}=${encodeURIComponent(cf)}`:u}).join("&");return`${a}?${c}${n}`}function hC(t,e){const n={...t,url:Q0(t.url),query:J0(t.query),headers:J0(t.headers),auth:Io(t.auth)};return e&&(delete n.body,delete n.urlencoded,delete n.formData,delete n.binary,delete n.graphql),n}const W0=new WeakMap;function pC(t){const e=W0.get(t.history);if(e&&e.historyBodies===t.historyBodies)return e.entries;const n=t.history.map(r=>{const s=t.historyBodies===!1&&r.transport!=="browser",a={...r,resolvedUrl:Q0(r.resolvedUrl),request:hC(r.request,s),responseHeaders:fC(r.responseHeaders)};return s&&(delete a.responseBody,delete a.responseBodyTruncated,delete a.requestBodyTruncated),a});return W0.set(t.history,{historyBodies:t.historyBodies,entries:n}),n}function Z0(t){const e=t.credentialStorage!==void 0&&t.credentialStorage!=="remember";return{...t,...e?{collections:t.collections.map(n=>({...n,auth:Io(n.auth)})),folders:t.folders.map(n=>({...n,auth:Io(n.auth)})),requests:t.requests.map(n=>({...n,request:{...n.request,auth:Io(n.request.auth)}}))}:{},history:pC(t)}}const mC="flexdoc-api-client",gC=1,tl="workspaces",yC="My Collection",ey=100,ty=256*1024,bC=256*1024;function pa(){return new Date().toISOString()}function Rn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Ke(t,e){return typeof t[e]=="string"}function Ho(t,e){const n=t[e];return n===void 0||typeof n=="number"&&Number.isFinite(n)}function zo(t){return!Rn(t)||!Ke(t,"key")||!Ke(t,"value")?!1:t.enabled===void 0||typeof t.enabled=="boolean"}function xC(t){if(!zo(t))return!1;const e=t;return!(e.type!==void 0&&e.type!=="text"&&e.type!=="file"||e.fileName!==void 0&&typeof e.fileName!="string"||e.contentType!==void 0&&typeof e.contentType!="string"||e.file!==void 0&&typeof File<"u"&&!(e.file instanceof File))}function vC(t){return!(!Rn(t)||t.fileName!==void 0&&typeof t.fileName!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.file!==void 0&&typeof File<"u"&&!(t.file instanceof File))}function Uo(t){if(!Rn(t)||typeof t.type!="string")return!1;if(t.type==="none"||t.type==="inherit")return!0;if(t.type==="bearer")return Ke(t,"token");if(t.type==="oauth2"){if(!Ke(t,"accessToken")||t.grantType!==void 0&&(typeof t.grantType!="string"||!["accessToken","authorizationCode","clientCredentials","password","implicit"].includes(t.grantType))||t.clientAuthentication!==void 0&&t.clientAuthentication!=="body"&&t.clientAuthentication!=="basic")return!1;for(const e of["authorizationUrl","tokenUrl","clientId","clientSecret","redirectUri","username","password","refreshToken"])if(t[e]!==void 0&&typeof t[e]!="string")return!1;return t.scopes===void 0||Array.isArray(t.scopes)&&t.scopes.every(e=>typeof e=="string")}return t.type==="basic"||t.type==="digest"?Ke(t,"username")&&Ke(t,"password"):t.type==="apiKey"?Ke(t,"key")&&Ke(t,"value")&&(t.in==="header"||t.in==="query"||t.in==="cookie"):t.type==="hawk"?Ke(t,"id")&&Ke(t,"key")&&(t.algorithm===void 0||t.algorithm==="sha1"||t.algorithm==="sha256")&&(t.ext===void 0||typeof t.ext=="string"):t.type==="ntlm"?Ke(t,"username")&&Ke(t,"password")&&(t.domain===void 0||typeof t.domain=="string")&&(t.workstation===void 0||typeof t.workstation=="string"):t.type==="oauth1"?Ke(t,"consumerKey")&&Ke(t,"consumerSecret")&&(t.token===void 0||typeof t.token=="string")&&(t.tokenSecret===void 0||typeof t.tokenSecret=="string")&&(t.realm===void 0||typeof t.realm=="string")&&(t.signatureMethod===void 0||["HMAC-SHA1","HMAC-SHA256","PLAINTEXT"].includes(String(t.signatureMethod))):t.type==="awsv4"?Ke(t,"accessKey")&&Ke(t,"secretKey")&&Ke(t,"region")&&Ke(t,"service")&&(t.sessionToken===void 0||typeof t.sessionToken=="string"):!1}function df(t){return`flexdoc:credentials:v1:${t}`}function wC(t){const e=[];for(const n of t.collections)e.push(["c",n.id,n.auth]);for(const n of t.folders)e.push(["f",n.id,n.auth]);for(const n of t.requests)n.request.auth&&e.push(["r",n.id,n.request.auth]);for(const n of t.history)n.request.auth&&e.push(["h",n.id,n.request.auth]);return e}function SC(t){const e=new Map;if(typeof sessionStorage>"u")return e;try{const n=JSON.parse(sessionStorage.getItem(df(t))||"[]");if(!Array.isArray(n))return e;for(const r of n)!Array.isArray(r)||r.length!==3||!["c","f","r","h"].includes(r[0])||typeof r[1]!="string"||!Uo(r[2])||e.set(`${r[0]}:${r[1]}`,r[2])}catch{}return e}function AC(t,e){if(e.credentialStorage!=="session")return e;const n=SC(t);return n.size===0?e:{...e,collections:e.collections.map(r=>({...r,auth:n.get(`c:${r.id}`)||r.auth})),folders:e.folders.map(r=>({...r,auth:n.get(`f:${r.id}`)||r.auth})),requests:e.requests.map(r=>({...r,request:{...r.request,auth:n.get(`r:${r.id}`)||r.request.auth}})),history:e.history.map(r=>({...r,request:{...r.request,auth:n.get(`h:${r.id}`)||r.request.auth}}))}}function kC(t,e){if(!(typeof sessionStorage>"u"))try{e.credentialStorage==="session"?sessionStorage.setItem(df(t),JSON.stringify(wC(e))):sessionStorage.removeItem(df(t))}catch{}}function ny(t){return!Rn(t)||!Ke(t,"method")||!Ke(t,"url")||t.query!==void 0&&(!Array.isArray(t.query)||!t.query.every(zo))||t.headers!==void 0&&(!Array.isArray(t.headers)||!t.headers.every(zo))||t.body!==void 0&&typeof t.body!="string"||t.contentType!==void 0&&typeof t.contentType!="string"||t.bodyMode!==void 0&&!["none","raw","json","urlencoded","formdata","binary","graphql"].includes(String(t.bodyMode))||t.urlencoded!==void 0&&(!Array.isArray(t.urlencoded)||!t.urlencoded.every(zo))||t.formData!==void 0&&(!Array.isArray(t.formData)||!t.formData.every(xC))||t.binary!==void 0&&!vC(t.binary)||t.graphql!==void 0&&(!Rn(t.graphql)||!Ke(t.graphql,"query")||!Ke(t.graphql,"variables"))||t.hostExecution!==void 0&&(!Rn(t.hostExecution)||t.hostExecution.certificateId!==void 0&&typeof t.hostExecution.certificateId!="string"||t.hostExecution.cookieJar!==void 0&&t.hostExecution.cookieJar!=="session"||t.hostExecution.preferHostExecution!==void 0&&typeof t.hostExecution.preferHostExecution!="boolean")?!1:t.auth===void 0||Uo(t.auth)}function iy(t){return Rn(t)&&Ke(t,"id")&&Ke(t,"key")&&Ke(t,"value")&&(t.enabled===void 0||typeof t.enabled=="boolean")}function CC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,auth:Uo(t.auth)?t.auth:{type:"none"},variables:Array.isArray(t.variables)?t.variables.filter(iy):[],createdAt:t.createdAt,updatedAt:t.updatedAt}}function NC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.parentFolderId!==void 0&&typeof t.parentFolderId!="string"||!Ke(t,"name")||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:t.name,auth:Uo(t.auth)?t.auth:{type:"inherit"},createdAt:t.createdAt,updatedAt:t.updatedAt}}function TC(t,e){const n=t.map(NC).filter(s=>s!==null).filter(s=>e.has(s.collectionId)),r=new Map(n.map(s=>[s.id,s]));for(const s of n){if(!s.parentFolderId)continue;const a=r.get(s.parentFolderId);(!a||a.collectionId!==s.collectionId||a.id===s.id)&&(s.parentFolderId=void 0)}for(const s of n){if(!s.parentFolderId)continue;const a=new Set([s.id]);let c=s.parentFolderId;for(;c;){if(a.has(c)){s.parentFolderId=void 0;break}a.add(c),c=r.get(c)?.parentFolderId}}return n}function ry(t){if(!(!Rn(t)||!Ke(t,"preRequest")||!Ke(t,"tests")))return{preRequest:t.preRequest,tests:t.tests}}function jC(t){if(!Rn(t)||!Ke(t,"id")||!Ke(t,"collectionId")||t.folderId!==void 0&&typeof t.folderId!="string"||!Ke(t,"name")||!ny(t.request)||!Ke(t,"createdAt")||!Ke(t,"updatedAt"))return null;const e=ry(t.scripts);return{id:t.id,collectionId:t.collectionId,folderId:t.folderId,name:t.name,request:Ei(t.request),...e?{scripts:e}:{},createdAt:t.createdAt,updatedAt:t.updatedAt}}function EC(t){return!Rn(t)||!Ke(t,"id")||!Ke(t,"name")||!Array.isArray(t.variables)||!Ke(t,"createdAt")||!Ke(t,"updatedAt")?null:{id:t.id,name:t.name,variables:t.variables.filter(iy),createdAt:t.createdAt,updatedAt:t.updatedAt}}function OC(t){return Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&typeof t[1]=="string"}function MC(t){return!Rn(t)||!Ke(t,"name")||typeof t.passed!="boolean"||t.error!==void 0&&typeof t.error!="string"?null:{name:t.name,passed:t.passed,error:t.error}}function RC(t){if(!Rn(t)||!Ke(t,"id")||!ny(t.request)||!Ke(t,"executedMethod")||!Ke(t,"resolvedUrl")||!Ho(t,"status")||t.statusText!==void 0&&typeof t.statusText!="string"||!Ho(t,"responseTime")||t.responseHeaders!==void 0&&(!Array.isArray(t.responseHeaders)||!t.responseHeaders.every(OC))||t.responseBody!==void 0&&typeof t.responseBody!="string"||t.responseBodyTruncated!==void 0&&typeof t.responseBodyTruncated!="boolean"||t.requestBodyTruncated!==void 0&&typeof t.requestBodyTruncated!="boolean"||t.runId!==void 0&&typeof t.runId!="string"||t.runName!==void 0&&typeof t.runName!="string"||!Ho(t,"runIndex")||!Ho(t,"runTotal")||t.runPassed!==void 0&&typeof t.runPassed!="boolean"||t.runCancelled!==void 0&&typeof t.runCancelled!="boolean"||t.error!==void 0&&typeof t.error!="string"||t.scriptError!==void 0&&typeof t.scriptError!="string"||!Ke(t,"createdAt"))return null;const e=ry(t.scripts),n=Array.isArray(t.scriptTests)?t.scriptTests.map(MC).filter(s=>s!==null):[],r=Array.isArray(t.scriptLogs)?t.scriptLogs.filter(s=>typeof s=="string"):[];return{id:t.id,collectionId:typeof t.collectionId=="string"?t.collectionId:void 0,folderId:typeof t.folderId=="string"?t.folderId:void 0,request:Ei(t.request),...e?{scripts:e}:{},executedMethod:t.executedMethod,resolvedUrl:t.resolvedUrl,status:t.status,statusText:t.statusText,responseTime:t.responseTime,transport:t.transport==="browser"||t.transport==="api-host"?t.transport:void 0,responseHeaders:Array.isArray(t.responseHeaders)?t.responseHeaders.map(([s,a])=>[s,a]):void 0,responseBody:typeof t.responseBody=="string"?t.responseBody:void 0,responseBodyTruncated:t.responseBodyTruncated===!0?!0:void 0,requestBodyTruncated:t.requestBodyTruncated===!0?!0:void 0,runId:typeof t.runId=="string"?t.runId:void 0,runName:typeof t.runName=="string"?t.runName:void 0,runIndex:typeof t.runIndex=="number"?t.runIndex:void 0,runTotal:typeof t.runTotal=="number"?t.runTotal:void 0,runPassed:typeof t.runPassed=="boolean"?t.runPassed:void 0,runCancelled:t.runCancelled===!0?!0:void 0,error:t.error,...n.length?{scriptTests:n}:{},...r.length?{scriptLogs:r}:{},scriptError:t.scriptError,createdAt:t.createdAt}}function sy(t){const e=Object.create(null);for(const n of t){const r=n.key.trim();n.enabled===!1||!r||(e[r]=n.value)}return e}function An(t){const e=globalThis.crypto?.randomUUID?.();return e?`${t}-${e}`:`${t}-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ly(t,e){const n=e?.trim()||"unknown-host",r=t?.trim()||"untitled";return`flexdoc:${encodeURIComponent(n)}:${encodeURIComponent(r)}`}function Ei(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n,file:void 0})),binary:t.binary?{...t.binary,file:void 0}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function nl(){const t=pa();return{version:6,credentialStorage:"session",collections:[{id:An("collection"),name:yC,auth:{type:"none"},variables:[],createdAt:t,updatedAt:t}],folders:[],requests:[],environments:[],history:[]}}function ay(t){if(!Rn(t)||![1,2,3,4,5,6].includes(t.version))return nl();const e=(Array.isArray(t.collections)?t.collections:[]).map(CC).filter(h=>h!==null);if(e.length===0)return nl();const n=new Set(e.map(h=>h.id)),r=TC(Array.isArray(t.folders)?t.folders:[],n),s=new Map(r.map(h=>[h.id,h])),a=(Array.isArray(t.requests)?t.requests:[]).map(jC).filter(h=>h!==null).filter(h=>n.has(h.collectionId)).map(h=>h.folderId?s.get(h.folderId)?.collectionId===h.collectionId?h:{...h,folderId:void 0}:h);if(t.version===1)return{version:6,collections:e,folders:r,requests:a,environments:[],history:[]};const c=(Array.isArray(t.environments)?t.environments:[]).map(EC).filter(h=>h!==null),u=typeof t.activeEnvironmentId=="string"&&c.some(h=>h.id===t.activeEnvironmentId)?t.activeEnvironmentId:void 0,f=(t.version===4||t.version===5||t.version===6)&&Array.isArray(t.history)?t.history.map(RC).filter(h=>h!==null).slice(0,ey):[];return{version:6,collections:e,folders:r,requests:a,environments:c,activeEnvironmentId:u,credentialStorage:t.credentialStorage==="session"||t.credentialStorage==="remember"||t.credentialStorage==="never"?t.credentialStorage:void 0,historyBodies:typeof t.historyBodies=="boolean"?t.historyBodies:void 0,history:f}}function DC(t){let e=bC,n=!1;const r=a=>{if(a.length<=e)return e-=a.length,a;const c=a.slice(0,e);return e=0,n=!0,c},s={...t};return s.body!==void 0&&(s.body=r(s.body)),s.graphql&&(s.graphql={query:r(s.graphql.query),variables:r(s.graphql.variables)}),s.urlencoded&&(s.urlencoded=s.urlencoded.map(a=>({...a,value:r(a.value)}))),s.formData&&(s.formData=s.formData.map(a=>({...a,value:r(a.value)}))),{request:s,truncated:n}}function oy(t,e){const n=e.responseBody===void 0?void 0:e.responseBody.slice(0,ty),r=e.responseBodyTruncated===!0||(e.responseBody?.length||0)>ty,s=DC(Ei(e.request)),a={id:An("history"),collectionId:e.collectionId,folderId:e.folderId,request:s.request,...s.truncated?{requestBodyTruncated:!0}:{},...e.scripts?{scripts:Sn(e.scripts)}:{},executedMethod:e.executedMethod,resolvedUrl:e.resolvedUrl,status:e.status,statusText:e.statusText,responseTime:e.responseTime,transport:e.transport,...e.responseHeaders?.length?{responseHeaders:e.responseHeaders.map(([c,u])=>[c,u])}:{},...n!==void 0?{responseBody:n,...r?{responseBodyTruncated:!0}:{}}:{},runId:e.runId,runName:e.runName,runIndex:e.runIndex,runTotal:e.runTotal,runPassed:e.runPassed,...e.runCancelled?{runCancelled:!0}:{},error:e.error,...e.scriptTests?.length?{scriptTests:e.scriptTests.map(c=>({...c}))}:{},...e.scriptLogs?.length?{scriptLogs:[...e.scriptLogs]}:{},scriptError:e.scriptError,createdAt:pa()};return{...t,history:[a,...t.history].slice(0,ey)}}function cy(t,e,n,r={type:"none"}){if(r.type!=="inherit")return{...r};const s=new Map(t.folders.map(f=>[f.id,f])),a=new Set;let c=n?s.get(n):void 0;for(;c&&c.collectionId===e&&!a.has(c.id);){if(a.add(c.id),c.auth.type!=="inherit")return{...c.auth};c=c.parentFolderId?s.get(c.parentFolderId):void 0}const u=t.collections.find(f=>f.id===e);return u&&u.auth.type!=="inherit"?{...u.auth}:{type:"none"}}function uy(t,e){const n=t.collections.find(r=>r.id===e);return sy(n?.variables||[])}function ff(t){const e=t.environments.find(n=>n.id===t.activeEnvironmentId);return sy(e?.variables||[])}function hf(t,e){if(!t.activeEnvironmentId||e.length===0)return t;const n=t.environments.findIndex(u=>u.id===t.activeEnvironmentId);if(n<0)return t;let s=t.environments[n].variables.map(u=>({...u})),a=!1;for(const u of e){const f=u.key.trim();if(!f)continue;if(u.action==="unset"){const b=s.filter(v=>v.key.trim()!==f);b.length!==s.length&&(s=b,a=!0);continue}const h=s.map((b,v)=>b.key.trim()===f?v:-1).filter(b=>b>=0),g=u.value||"";if(h.length>0){const b=h[0];s[b]={...s[b],key:f,value:g,enabled:!0},h.length>1&&(s=s.filter((v,w)=>w===b||v.key.trim()!==f))}else s.push({id:An("variable"),key:f,value:g,enabled:!0});a=!0}if(!a)return t;const c=t.environments.map((u,f)=>f===n?{...u,variables:s,updatedAt:pa()}:u);return{...t,environments:c}}function dy(t,e,n){if(!e||n.length===0)return t;const r=t.collections.findIndex(f=>f.id===e);if(r<0)return t;let a=t.collections[r].variables.map(f=>({...f})),c=!1;for(const f of n){const h=f.key.trim();if(!h)continue;if(f.action==="unset"){const v=a.filter(w=>w.key.trim()!==h);v.length!==a.length&&(a=v,c=!0);continue}const g=a.map((v,w)=>v.key.trim()===h?w:-1).filter(v=>v>=0),b=f.value||"";if(g.length>0){const v=g[0];a[v]={...a[v],key:h,value:b,enabled:!0},g.length>1&&(a=a.filter((w,A)=>A===v||w.key.trim()!==h))}else a.push({id:An("variable"),key:h,value:b,enabled:!0});c=!0}if(!c)return t;const u=t.collections.map((f,h)=>h===r?{...f,variables:a,updatedAt:pa()}:f);return{...t,collections:u}}function _C(t,e){return{...t,environments:t.environments.filter(n=>n.id!==e),activeEnvironmentId:t.activeEnvironmentId===e?void 0:t.activeEnvironmentId}}function LC(t,e){const n=t.folders.find(s=>s.id===e);if(!n)return t;const r=pa();return{...t,folders:t.folders.filter(s=>s.id!==e).map(s=>s.parentFolderId===e?{...s,parentFolderId:n.parentFolderId,updatedAt:r}:s),requests:t.requests.map(s=>s.folderId===e?{...s,folderId:n.parentFolderId,updatedAt:r}:s)}}function qC(t,e){const n=t.collections.filter(r=>r.id!==e);return n.length===0?{...nl(),environments:t.environments,activeEnvironmentId:t.activeEnvironmentId,credentialStorage:t.credentialStorage,history:t.history}:{...t,collections:n,folders:t.folders.filter(r=>r.collectionId!==e),requests:t.requests.filter(r=>r.collectionId!==e)}}function fy(){return typeof indexedDB>"u"?Promise.resolve(null):new Promise((t,e)=>{const n=indexedDB.open(mC,gC);n.onupgradeneeded=()=>{const r=n.result;r.objectStoreNames.contains(tl)||r.createObjectStore(tl)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error||new Error("Unable to open FlexDoc API Client storage"))})}async function hy(t){const e=await fy();if(!e)return nl();try{return await new Promise((n,r)=>{const a=e.transaction(tl,"readonly").objectStore(tl).get(t);a.onsuccess=()=>n(AC(t,ay(a.result))),a.onerror=()=>r(a.error||new Error("Unable to load FlexDoc API Client workspace"))})}finally{e.close()}}async function py(t,e){kC(t,e);const n=await fy();if(n)try{await new Promise((r,s)=>{const a=n.transaction(tl,"readwrite");a.objectStore(tl).put(Z0(e),t),a.oncomplete=()=>r(),a.onerror=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace")),a.onabort=()=>s(a.error||new Error("Unable to save FlexDoc API Client workspace"))})}finally{n.close()}}const BC=300;function $C(t,e){return t.requests===e.requests&&t.folders===e.folders&&t.history===e.history&&t.version===e.version&&t.activeEnvironmentId===e.activeEnvironmentId&&t.credentialStorage===e.credentialStorage&&t.historyBodies===e.historyBodies}function my(t,e,n){const[r,s]=I.useState(!1),a=I.useRef(e),c=I.useRef(t),u=I.useRef(n),f=I.useRef(!1),h=I.useRef(null);return I.useEffect(()=>{a.current=e,c.current=t,u.current=n}),I.useEffect(()=>{if(!n||t===!1)return;const g=()=>{f.current=!1,py(t,e).then(()=>s(!1)).catch(()=>s(!0))},b=h.current;if(h.current=e,b&&$C(b,e)){f.current=!0;const v=setTimeout(g,BC);return()=>clearTimeout(v)}g()},[n,t,e]),I.useEffect(()=>{const g=()=>{const b=c.current;!f.current||!u.current||b===!1||(f.current=!1,py(b,a.current).catch(()=>{}))};return typeof window<"u"&&window.addEventListener("pagehide",g),()=>{typeof window<"u"&&window.removeEventListener("pagehide",g),g()}},[]),r}const IC=["browser","api-host"];function pf(t,e){if(t.length===1)return t[0];const n=Math.ceil(e*t.length);return t[Math.min(Math.max(n,1),t.length)-1]}function HC(t){return t>=200&&t<300?"2xx":t>=300&&t<400?"3xx":t>=400&&t<500?"4xx":t>=500&&t<600?"5xx":"other"}function zC(t={}){const e=Math.max(1,Math.floor(t.durationSampleCapacity??2048)),n=t.now??(()=>Date.now()),r=t.random??Math.random;let s=null,a=null,c=0,u={},f;const h=()=>({observed:0,retained:[]}),g=()=>({attempts:0,responses:0,failures:0,networkFailures:0,statusClasses:{"2xx":0,"3xx":0,"4xx":0,"5xx":0,other:0},total:h(),target:h(),overhead:h()}),b=()=>{f={browser:g(),"api-host":g()}};b();const v=(D,O)=>{if(typeof O!="number"||!Number.isFinite(O))return;const j=Math.max(0,O);if(D.observed+=1,D.retained.length{if(D.retained.length===0)return null;const O=[...D.retained].sort((j,R)=>j-R);return{sampleCount:O.length,sampled:D.observed>O.length,minMs:O[0],p50Ms:pf(O,.5),p95Ms:pf(O,.95),p99Ms:pf(O,.99),maxMs:O[O.length-1]}};return{record:D=>{const O=n();s===null&&(s=O),a=O,c+=1;const j=D.response?.transport??D.result?.transport;if(j!=="browser"&&j!=="api-host"){const M=D.result?"host-unavailable":D.scriptError?"script-error":"request-invalid";u[M]=(u[M]??0)+1;return}const R=f[j];R.attempts+=1;const _=D.response;if(!_){R.failures+=1,D.failureKind==="browser-network"&&(R.networkFailures+=1);return}if(R.responses+=1,R.statusClasses[HC(_.status)]+=1,j==="browser"){v(R.total,_.responseTime);return}const L=_.hostRoundTripTime??_.responseTime;v(R.total,L),v(R.target,_.responseTime),typeof _.hostRoundTripTime=="number"&&typeof _.responseTime=="number"&&v(R.overhead,Math.max(0,_.hostRoundTripTime-_.responseTime))},snapshot:()=>({windowStart:s===null?null:new Date(s).toISOString(),windowEnd:a===null?null:new Date(a).toISOString(),executions:c,byTransport:IC.reduce((D,O)=>{const j=f[O];return D[O]={attempts:j.attempts,responses:j.responses,failures:j.failures,networkFailures:j.networkFailures,statusClasses:{...j.statusClasses},totalDurations:w(j.total),targetDurations:w(j.target),hostOverhead:w(j.overhead)},D},{}),unexecuted:{...u}}),reset:()=>{s=null,a=null,c=0,u={},b()}}}function UC(t,e=new Date().toISOString()){return{schema:"flexdoc.api-client.transport-observation/1",generatedAt:e,observation:t,pairsWith:"flexdoc.host-execution.observation/1",gaps:["host-side-rejection-reasons"]}}const mf=zC();function VC(t){mf.record(t)}function FC(){return mf.snapshot()}function PC(){mf.reset()}const YC={cookies:"Cookie jar",clientCertificates:"Client certificates (mTLS)",digest:"Digest auth",hawk:"Hawk auth",ntlm:"NTLM auth",oauth1:"OAuth 1.0",awsv4:"AWS Signature V4"};function gy(t){return YC[t]}function gf(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function KC(t){const e=gf(t);return e.binary&&(e.binary={fileName:e.binary.fileName,contentType:e.binary.contentType}),e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),e}function Vo(t){return Object.assign(Object.create(null),t||{})}function GC(t){return t instanceof Error?t.message:"Request failed"}function XC(t){return t?Array.isArray(t)?t.map(([e,n])=>[String(e),String(n)]):[...new Headers(t).entries()]:[]}function JC(t,e){if(e.body!=null&&typeof e.body!="string")return;const r=[`curl -X ${String(e.method||"GET").toUpperCase()} ${JSON.stringify(t)}`];for(const[s,a]of XC(e.headers))r.push(` -H ${JSON.stringify(`${s}: ${a}`)}`);return typeof e.body=="string"&&e.body.length>0&&r.push(` --data-raw ${JSON.stringify(e.body)}`),r.join(` \\ +`)}function yy(t,e){return e?.available?`The API host does not support: ${t.map(gy).join(", ")}.`:"API-host execution is unavailable on this documentation server."}function Fo(t){const e=(t.request.method||"GET").toUpperCase(),n=[...new Set([...tC(t.request),...t.additionalRequirements||[]])],r=["GET","HEAD"].includes(e)&&ha(t.request)!=="none",s=t.request.hostExecution?.preferHostExecution,a=t.hostExecution?.preferHostExecution,c=a===!1?!1:t.preferHostExecution??s??a??!0,u=new Set(t.hostExecution?.capabilities||[]),f=n.filter(b=>!u.has(b)),h=n.length>0||r,g=t.hostExecution?.available===!0&&f.length===0;return[h?"host-required":c&&t.hostExecution?.available===!0?"api-host":"browser",g,r,f]}function QC(t){return t==="host-required"?"Host required":t==="api-host"?"API host":"Browser"}function WC(t,e,n){return t.failureKind!=="browser-network"||t.result?.transport!=="browser"?null:Fo({request:e,hostExecution:n,preferHostExecution:!0})[0]==="api-host"?"Browser request failed (possibly CORS). Try API host.":null}const ZC=500;function eN(t,e,n){const r=t?.hostRoundTripTime??t?.responseTime;return t?.transport!=="api-host"||r==null||r({entry:r,index:s})).filter(({entry:r})=>r.enabled!==!1&&r.type==="file"&&!!r.file);if(n.length>0){if(typeof FormData>"u")throw new Error("Host multipart execution requires FormData support.");const r=new FormData;r.append("descriptor",JSON.stringify(e));for(const{entry:s,index:a}of n){const c=s.file;r.append(`formData[${a}]`,c,s.fileName||c.name)}return{body:r,headers:{"X-FlexDoc-Execute":"1"}}}return{body:JSON.stringify(e),headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"}}}async function by(t){const e=await rN(t);return VC(e),e}async function rN(t){const e=gf(t.request),n=Sn(t.scripts),r=t.fetcher||globalThis.fetch,s=t.now||Date.now;let a=gf(t.request),c=Vo(t.variables),u=Vo(t.collectionVariables);const f=Vo(t.externalVariables);let h=Vo(t.environmentVariables),g=[],b=[],v,w="",A="",C=0,E=!1,D,O;try{if(n.preRequest.trim()){const M=await F0({script:n.preRequest,phase:"pre-request",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h});if(a=M.draft,c=M.variables,u=M.collectionVariables,h=M.environmentVariables,g=[...g,...M.logs],M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error)return{scriptTests:b,scriptLogs:g,scriptError:`Pre-request script: ${M.error}`}}t.resolveAuth&&(a={...a,auth:t.resolveAuth(a.auth)}),a=nC(a,c),w=(a.method||"GET").toUpperCase(),A=a.url;const[j,,,R]=Fo({request:a,hostExecution:t.hostExecution,preferHostExecution:t.preferHostExecution});let _;if(j!=="browser"){if(!t.hostExecution?.available||R.length>0){const ge=yy(R,t.hostExecution);return{error:ge,result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,error:ge,...g.length?{scriptLogs:[...g]}:{}},scriptTests:b,scriptLogs:g}}if(!r)throw new Error("Fetch API is not available");const M=await iN(a);C=s(),E=!0,D="api-host";const G=await r(t.hostExecution.endpoint,{method:"POST",credentials:"same-origin",headers:M.headers,body:M.body,...t.signal?{signal:t.signal}:{}}),Y=await G.text(),B=s()-C;let K;try{const ge=Y?JSON.parse(Y):{};if(!ge||typeof ge!="object"||Array.isArray(ge))throw new Error("invalid");K=ge}catch{throw new Error("API host returned an invalid execution response.")}const ee=typeof K.error=="string"?K.error:void 0;if(!G.ok)throw new Error(ee||`API host execution failed with HTTP ${G.status}.`);if(typeof K.status!="number"||!Array.isArray(K.headers))throw new Error("API host returned an invalid execution response.");const be=K.headers.map(ge=>Array.isArray(ge)?[String(ge[0]),String(ge[1])]:["",""]).filter(([ge])=>!!ge),ce=Array.isArray(K.cookies)?K.cookies:void 0;_={status:K.status,statusText:String(K.statusText||""),headers:be,body:String(K.body||""),responseTime:typeof K.responseTime=="number"?K.responseTime:B,hostRoundTripTime:B,transport:"api-host",...ce?{cookies:ce}:{}}}else{const M=G0(a);w=M.method,A=M.url,t.onRequestBuilt?.(M);let G={...M.init,url:M.url,credentials:t.credentials||"same-origin",...t.signal?{signal:t.signal}:{}};t.requestInterceptor&&(G=await t.requestInterceptor(G)),t.signal&&(G.signal=t.signal);const{url:Y,...B}=G;if(A=Y,O=JC(Y,B),C=s(),E=!0,D="browser",!r)throw new Error("Fetch API is not available");const K=await r(Y,B),ee=await K.text();_={status:K.status,statusText:K.statusText,headers:[...K.headers.entries()],body:ee,responseTime:s()-C,transport:"browser"}}if(n.tests.trim()){const M=await F0({script:n.tests,phase:"tests",draft:a,variables:c,collectionVariables:u,externalVariables:f,environmentVariables:h,response:_});g=[...g,...M.logs],b=M.tests.map(G=>({...G})),M.collectionChanges.length>0&&t.onCollectionChanges?.(M.collectionChanges),M.environmentChanges.length>0&&t.onEnvironmentChanges?.(M.environmentChanges),M.error&&(v=`Test script: ${M.error}`)}return{result:{request:e,scripts:n,executedMethod:w,resolvedUrl:A,status:_.status,statusText:_.statusText,responseTime:_.responseTime,transport:_.transport,responseHeaders:_.headers.map(([M,G])=>[M,G]),responseBody:_.body,...b.length?{scriptTests:b}:{},...g.length?{scriptLogs:[...g]}:{},...v?{scriptError:v}:{}},response:_,scriptTests:b,scriptLogs:g,...O?{curlCommand:O}:{},...v?{scriptError:v}:{}}}catch(j){const R=GC(j),_={error:R,scriptTests:b,scriptLogs:g,...D==="browser"&&j instanceof TypeError?{failureKind:"browser-network"}:{}};return E&&(_.result={request:e,scripts:n,executedMethod:w,resolvedUrl:A,responseTime:C?s()-C:void 0,transport:D,error:R,...g.length?{scriptLogs:[...g]}:{}}),_}}const sN=()=>p.jsx("span",{"aria-hidden":"true",className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-blue-600 text-xs font-bold text-white",children:"F"});function yf({message:t,capabilities:e=[],showCapabilities:n=!0,warning:r=!1,theme:s="light",label:a="Host execution status"}){const c=r?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-blue-800 bg-blue-950/40 text-blue-200":"border-blue-300 bg-blue-50 text-blue-800";return p.jsx("div",{role:r?"alert":"status","aria-label":a,className:`rounded-md border p-3 text-sm ${c}`,children:p.jsxs("div",{className:"flex items-start gap-2",children:[p.jsx(sN,{}),p.jsxs("div",{children:[t,n&&p.jsxs("details",{className:"mt-1",children:[p.jsx("summary",{children:"API host capabilities"}),p.jsxs("div",{className:"mt-1 text-xs",children:["Universal: HTTP method, URL, query, headers, body · Host-specific: ",e.length?e.map(gy).join(" · "):"None advertised."]})]})]})]})})}function il(t,e){const n=t?.trim();if(!n)throw new Error(`${e} is required for this OAuth flow.`);return n}function Po(t){return(t.scopes||[]).map(e=>e.trim()).filter(Boolean).join(" ")}function lN(t){if(typeof TextEncoder>"u")throw new Error("OAuth Basic client authentication requires UTF-8 encoding support.");const e=new TextEncoder().encode(t);let n="";for(const a of e)n+=String.fromCharCode(a);const r=globalThis.Buffer,s=typeof btoa=="function"?btoa(n):r?.from(n,"binary").toString("base64");if(!s)throw new Error("OAuth Basic client authentication requires Base64 support in this runtime.");return s}function xy(t){let e="";for(const s of t)e+=String.fromCharCode(s);const n=globalThis.Buffer,r=typeof btoa=="function"?btoa(e):n?.from(e,"binary").toString("base64");if(!r)throw new Error("OAuth PKCE requires Base64 support in this runtime.");return r.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/g,"")}function vy(t=32){if(!globalThis.crypto?.getRandomValues)throw new Error("OAuth requires cryptographic random-number support.");const e=new Uint8Array(t);return globalThis.crypto.getRandomValues(e),xy(e)}async function aN(t){if(!globalThis.crypto?.subtle||typeof TextEncoder>"u")throw new Error("OAuth authorization-code flow requires Web Crypto PKCE support.");const e=await globalThis.crypto.subtle.digest("SHA-256",new TextEncoder().encode(t));return xy(new Uint8Array(e))}function wy(t,e,n,r){const s=il(t.authorizationUrl,"Authorization URL"),a=il(t.clientId,"Client ID"),c=new URL(s),u=t.grantType||"accessToken";c.searchParams.set("response_type",u==="implicit"?"token":"code"),c.searchParams.set("client_id",a),c.searchParams.set("redirect_uri",n),c.searchParams.set("state",e);const f=Po(t);return f&&c.searchParams.set("scope",f),r&&(c.searchParams.set("code_challenge",r),c.searchParams.set("code_challenge_method","S256")),c.toString()}function oN(t){const e=new URL(t.location.href);return e.search="",e.hash="",e.toString()}async function cN(t,e){const n=e??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=t.redirectUri?.trim()||oN(n);if(new URL(r).origin!==n.location.origin)throw new Error("Interactive OAuth redirect URI must use the same origin as the FlexDoc page so the popup result can be read.");const s=vy(24);if((t.grantType||"accessToken")==="implicit")return{url:wy(t,s,r),state:s,redirectUri:r};const a=vy(48),c=await aN(a);return{url:wy(t,s,r,c),state:s,redirectUri:r,codeVerifier:a}}async function uN(t){const e=await t.text();let n;try{n=e?JSON.parse(e):{}}catch{n=Object.fromEntries(new URLSearchParams(e))}if(!t.ok){const c=String(n.error_description||n.error||`OAuth token endpoint returned ${t.status}`);throw new Error(c)}const r=typeof n.access_token=="string"?n.access_token:"";if(!r)throw new Error("OAuth token endpoint did not return access_token.");const s=n.expires_in,a=typeof s=="number"?s:typeof s=="string"&&s.trim()!==""&&Number.isFinite(Number(s))?Number(s):void 0;return{accessToken:r,refreshToken:typeof n.refresh_token=="string"?n.refresh_token:void 0,tokenType:typeof n.token_type=="string"?n.token_type:void 0,expiresIn:a,scope:typeof n.scope=="string"?n.scope:void 0}}async function Yo(t,e,n){const r=il(t.tokenUrl,"Token URL"),s={"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"},a=t.clientId?.trim();(t.clientAuthentication||"body")==="basic"&&a?s.Authorization=`Basic ${lN(`${a}:${t.clientSecret||""}`)}`:(a&&e.set("client_id",a),t.clientSecret&&e.set("client_secret",t.clientSecret));const c=await n(r,{method:"POST",headers:s,body:e.toString()});return uN(c)}async function dN(t,e){const n=e.windowObject??(typeof window>"u"?void 0:window);if(!n)throw new Error("Interactive OAuth requires a browser window.");const r=n.open(t.url,"flexdoc-oauth","popup,width=640,height=760");if(!r)throw new Error("OAuth popup was blocked. Allow popups for this documentation origin and try again.");const s=new URL(t.redirectUri),a=Date.now(),c=e.popupTimeoutMs??12e4,u=e.pollIntervalMs??200;for(;Date.now()-asetTimeout(f,u))}throw r.close(),new Error("OAuth authorization timed out.")}async function fN(t,e={}){const n=t.grantType||"accessToken",r=e.fetchImpl??fetch;if(n==="accessToken")return{accessToken:il(t.accessToken,"Access token")};if(n==="clientCredentials"){const b=new URLSearchParams({grant_type:"client_credentials"}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}if(n==="password"){const b=new URLSearchParams({grant_type:"password",username:il(t.username,"Username"),password:t.password||""}),v=Po(t);return v&&b.set("scope",v),Yo(t,b,r)}const s=await cN(t,e.windowObject),a=await dN(s,e);if((a.searchParams.get("state")||new URLSearchParams(a.hash.replace(/^#/,"")).get("state"))!==s.state)throw new Error("OAuth state mismatch; authorization response was rejected.");const u=new URLSearchParams(a.hash.replace(/^#/,"")),f=a.searchParams.get("error")||u.get("error");if(f){const b=a.searchParams.get("error_description")||u.get("error_description");throw new Error(b||f)}if(n==="implicit"){const b=u.get("access_token")||"";if(!b)throw new Error("OAuth implicit response did not include access_token.");return{accessToken:b,tokenType:u.get("token_type")||void 0,expiresIn:u.get("expires_in")?Number(u.get("expires_in")):void 0,scope:u.get("scope")||void 0}}const h=a.searchParams.get("code");if(!h)throw new Error("OAuth authorization response did not include code.");const g=new URLSearchParams({grant_type:"authorization_code",code:h,redirect_uri:s.redirectUri});return s.codeVerifier&&g.set("code_verifier",s.codeVerifier),Yo(t,g,r)}async function hN(t,e={}){const n=il(t.refreshToken,"Refresh token"),r=new URLSearchParams({grant_type:"refresh_token",refresh_token:n}),s=Po(t);return s&&r.set("scope",s),Yo(t,r,e.fetchImpl??fetch)}function pN(t){return t==="inherit"?{type:"inherit"}:t==="bearer"?{type:"bearer",token:""}:t==="oauth2"?{type:"oauth2",accessToken:"",grantType:"accessToken",scopes:[]}:t==="basic"?{type:"basic",username:"",password:""}:t==="apiKey"?{type:"apiKey",key:"",value:"",in:"header"}:t==="digest"?{type:"digest",username:"",password:""}:t==="hawk"?{type:"hawk",id:"",key:"",algorithm:"sha256"}:t==="ntlm"?{type:"ntlm",username:"",password:""}:t==="oauth1"?{type:"oauth1",consumerKey:"",consumerSecret:"",signatureMethod:"HMAC-SHA1"}:t==="awsv4"?{type:"awsv4",accessKey:"",secretKey:"",region:"",service:""}:{type:"none"}}function mN(t){return t.split(/\s+/).map(e=>e.trim()).filter(Boolean)}const gN=({auth:t,fieldClass:e,label:n,onChange:r})=>{const[s,a]=I.useState(!1),[c,u]=I.useState(null),f=t.grantType||"accessToken",h=f==="authorizationCode"||f==="implicit",g=f==="authorizationCode"||f==="clientCredentials"||f==="password",b=f!=="accessToken",v=async()=>{a(!0),u(null);try{const A=await fN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u(A.expiresIn?`Access token acquired; expires in ${A.expiresIn}s.`:"Access token acquired.")}catch(A){u(A instanceof Error?A.message:"OAuth authorization failed.")}finally{a(!1)}},w=async()=>{a(!0),u(null);try{const A=await hN(t);r({...t,accessToken:A.accessToken,refreshToken:A.refreshToken??t.refreshToken}),u("Access token refreshed.")}catch(A){u(A instanceof Error?A.message:"OAuth token refresh failed.")}finally{a(!1)}};return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":n?`${n} OAuth grant type`:"OAuth grant type",className:e,value:f,onChange:A=>r({...t,grantType:A.target.value}),children:[p.jsx("option",{value:"accessToken",children:"Manual access token"}),p.jsx("option",{value:"authorizationCode",children:"Authorization Code + PKCE"}),p.jsx("option",{value:"clientCredentials",children:"Client Credentials"}),p.jsx("option",{value:"password",children:"Password grant (legacy)"}),p.jsx("option",{value:"implicit",children:"Implicit grant (legacy)"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth authorization URL`:"OAuth authorization URL",className:e,placeholder:"Authorization URL",value:t.authorizationUrl||"",onChange:A=>r({...t,authorizationUrl:A.target.value})}),g&&p.jsx("input",{"aria-label":n?`${n} OAuth token URL`:"OAuth token URL",className:e,placeholder:"Token URL",value:t.tokenUrl||"",onChange:A=>r({...t,tokenUrl:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth client ID`:"OAuth client ID",className:e,placeholder:"Client ID",value:t.clientId||"",onChange:A=>r({...t,clientId:A.target.value})}),(f==="authorizationCode"||f==="clientCredentials"||f==="password")&&p.jsx("input",{"aria-label":n?`${n} OAuth client secret`:"OAuth client secret",type:"password",autoComplete:"off",className:e,placeholder:f==="authorizationCode"?"Client secret (optional for PKCE/public clients)":"Client secret (optional)",value:t.clientSecret||"",onChange:A=>r({...t,clientSecret:A.target.value})}),g&&p.jsxs("select",{"aria-label":n?`${n} OAuth client authentication`:"OAuth client authentication",className:e,value:t.clientAuthentication||"body",onChange:A=>r({...t,clientAuthentication:A.target.value}),children:[p.jsx("option",{value:"body",children:"Send client credentials in body"}),p.jsx("option",{value:"basic",children:"Send as Basic Auth header"})]}),h&&p.jsx("input",{"aria-label":n?`${n} OAuth redirect URI`:"OAuth redirect URI",className:e,placeholder:"Redirect URI (defaults to this page)",value:t.redirectUri||"",onChange:A=>r({...t,redirectUri:A.target.value})}),b&&p.jsx("input",{"aria-label":n?`${n} OAuth scopes`:"OAuth scopes",className:e,placeholder:"Scopes separated by spaces",value:(t.scopes||[]).join(" "),onChange:A=>r({...t,scopes:mN(A.target.value)})}),f==="password"&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":n?`${n} OAuth username`:"OAuth username",className:e,placeholder:"Resource owner username",value:t.username||"",onChange:A=>r({...t,username:A.target.value})}),p.jsx("input",{"aria-label":n?`${n} OAuth password`:"OAuth password",type:"password",autoComplete:"off",className:e,placeholder:"Resource owner password",value:t.password||"",onChange:A=>r({...t,password:A.target.value})})]}),p.jsx("input",{"aria-label":n?`${n} OAuth access token`:"OAuth access token",type:"password",autoComplete:"off",className:e,placeholder:"Access token",value:t.accessToken,onChange:A=>r({...t,accessToken:A.target.value})}),f!=="accessToken"&&p.jsxs("div",{className:"flex flex-wrap gap-2",children:[p.jsx("button",{type:"button",disabled:s,onClick:v,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:s?"Authorizing…":"Get access token"}),t.refreshToken&&t.tokenUrl&&p.jsx("button",{type:"button",disabled:s,onClick:w,className:"rounded-md border px-2.5 py-1.5 text-xs font-medium disabled:opacity-60",children:"Refresh access token"})]}),f!=="accessToken"&&p.jsx("p",{className:"text-[11px] opacity-70",children:"Authorization Code uses PKCE. Popup callbacks must return to this page origin; token endpoints must allow browser CORS. Client secrets entered here are browser-visible and should only be used when the OAuth provider permits it."}),c&&p.jsx("p",{role:"status",className:"text-xs",children:c})]})},bf=({auth:t,label:e,allowInherit:n=!1,advanced:r=!0,hostExecution:s,onChange:a,theme:c})=>{const f=`w-full rounded-md border ${e?"px-2 py-1.5 text-xs":"px-3 py-2 text-sm"} ${c==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900"}`,h=(w,A=w)=>e?`${e} ${w}`:A,g=new Set(s?.capabilities||[]),b=w=>s?.available===!0&&g.has(w),v=t.type==="digest"?"digest":t.type==="hawk"?"hawk":t.type==="ntlm"?"ntlm":t.type==="oauth1"?"oauth1":t.type==="awsv4"?"awsv4":t.type==="apiKey"&&t.in==="cookie"?"cookies":void 0;return p.jsxs("div",{className:"space-y-2",children:[p.jsxs("select",{"aria-label":h("authorization type","Authorization type"),className:f,value:t.type==="inherit"&&!n?"none":t.type,onChange:w=>a(pN(w.target.value)),children:[n&&p.jsx("option",{value:"inherit",children:"Inherit from parent"}),p.jsx("option",{value:"none",children:"No auth"}),p.jsx("option",{value:"bearer",children:"Bearer token"}),p.jsx("option",{value:"basic",children:"Basic auth"}),p.jsx("option",{value:"apiKey",children:"API key"}),(r||t.type==="oauth2")&&p.jsx("option",{value:"oauth2",children:"OAuth 2.0"}),r&&p.jsxs(p.Fragment,{children:[p.jsx("option",{value:"digest",disabled:!b("digest"),children:"Digest (API host)"}),p.jsx("option",{value:"hawk",disabled:!b("hawk"),children:"Hawk (API host)"}),p.jsx("option",{value:"ntlm",disabled:!b("ntlm"),children:"NTLM / Negotiate (API host)"}),p.jsx("option",{value:"oauth1",disabled:!b("oauth1"),children:"OAuth 1.0 (API host)"}),p.jsx("option",{value:"awsv4",disabled:!b("awsv4"),children:"AWS Signature v4 (API host)"})]})]}),t.type==="bearer"&&p.jsx("input",{"aria-label":h("bearer token","Bearer token"),type:"password",autoComplete:"off",className:f,value:t.token,onChange:w=>a({...t,token:w.target.value})}),t.type==="oauth2"&&p.jsx(gN,{auth:t,fieldClass:f,label:e,onChange:a}),(t.type==="basic"||t.type==="digest")&&p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{"aria-label":h(t.type+" username",t.type==="basic"?"Basic auth username":"Digest username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h(t.type+" password",t.type==="basic"?"Basic auth password":"Digest password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})})]}),t.type==="apiKey"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("input",{"aria-label":h("API key name"),className:f,placeholder:"Key name",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsx("input",{"aria-label":h("API key value"),type:"password",autoComplete:"off",className:f,placeholder:"Value",value:t.value,onChange:w=>a({...t,value:w.target.value})}),p.jsxs("select",{"aria-label":h("API key location"),className:f,value:t.in,onChange:w=>a({...t,in:w.target.value}),children:[p.jsx("option",{value:"header",children:"Header"}),p.jsx("option",{value:"query",children:"Query"}),p.jsx("option",{value:"cookie",disabled:!b("cookies"),children:"Cookie (API host)"})]})]}),t.type==="hawk"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("Hawk id"),className:f,placeholder:"ID",value:t.id,onChange:w=>a({...t,id:w.target.value})}),p.jsx("input",{"aria-label":h("Hawk key"),type:"password",autoComplete:"off",className:f,placeholder:"Key",value:t.key,onChange:w=>a({...t,key:w.target.value})}),p.jsxs("select",{"aria-label":h("Hawk algorithm"),className:f,value:t.algorithm||"sha256",onChange:w=>a({...t,algorithm:w.target.value}),children:[p.jsx("option",{value:"sha256",children:"SHA-256"}),p.jsx("option",{value:"sha1",children:"SHA-1"})]}),p.jsx("input",{"aria-label":h("Hawk ext"),className:f,placeholder:"ext (optional)",value:t.ext||"",onChange:w=>a({...t,ext:w.target.value})})]}),t.type==="ntlm"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("NTLM username"),className:f,placeholder:"Username",value:t.username,onChange:w=>a({...t,username:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM password"),type:"password",autoComplete:"off",className:f,placeholder:"Password",value:t.password,onChange:w=>a({...t,password:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM domain"),className:f,placeholder:"Domain (optional)",value:t.domain||"",onChange:w=>a({...t,domain:w.target.value})}),p.jsx("input",{"aria-label":h("NTLM workstation"),className:f,placeholder:"Workstation (optional)",value:t.workstation||"",onChange:w=>a({...t,workstation:w.target.value})})]}),t.type==="oauth1"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("OAuth1 consumer key"),className:f,placeholder:"Consumer key",value:t.consumerKey,onChange:w=>a({...t,consumerKey:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 consumer secret"),type:"password",autoComplete:"off",className:f,placeholder:"Consumer secret",value:t.consumerSecret,onChange:w=>a({...t,consumerSecret:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token"),className:f,placeholder:"Token (optional)",value:t.token||"",onChange:w=>a({...t,token:w.target.value})}),p.jsx("input",{"aria-label":h("OAuth1 token secret"),type:"password",autoComplete:"off",className:f,placeholder:"Token secret (optional)",value:t.tokenSecret||"",onChange:w=>a({...t,tokenSecret:w.target.value})}),p.jsxs("select",{"aria-label":h("OAuth1 signature method"),className:f,value:t.signatureMethod||"HMAC-SHA1",onChange:w=>a({...t,signatureMethod:w.target.value}),children:[p.jsx("option",{children:"HMAC-SHA1"}),p.jsx("option",{children:"HMAC-SHA256"}),p.jsx("option",{children:"PLAINTEXT"})]}),p.jsx("input",{"aria-label":h("OAuth1 realm"),className:f,placeholder:"Realm (optional)",value:t.realm||"",onChange:w=>a({...t,realm:w.target.value})})]}),t.type==="awsv4"&&p.jsxs("div",{className:"grid gap-2",children:[p.jsx("input",{"aria-label":h("AWS access key"),className:f,placeholder:"Access key",value:t.accessKey,onChange:w=>a({...t,accessKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS secret key"),type:"password",autoComplete:"off",className:f,placeholder:"Secret key",value:t.secretKey,onChange:w=>a({...t,secretKey:w.target.value})}),p.jsx("input",{"aria-label":h("AWS session token"),type:"password",autoComplete:"off",className:f,placeholder:"Session token (optional)",value:t.sessionToken||"",onChange:w=>a({...t,sessionToken:w.target.value})}),p.jsx("input",{"aria-label":h("AWS region"),className:f,placeholder:"Region",value:t.region,onChange:w=>a({...t,region:w.target.value})}),p.jsx("input",{"aria-label":h("AWS service"),className:f,placeholder:"Service",value:t.service,onChange:w=>a({...t,service:w.target.value})})]}),e&&v&&p.jsx("p",{role:b(v)?"status":"alert",className:"text-[11px] opacity-75",children:b(v)?"This authorization mode is executed by the FlexDoc API host.":s?.available?"Requests run from your API server, but this authorization mode is not supported.":"API-host execution is unavailable on this documentation server."})]})};let xf=[],Sy=[];(()=>{let t="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,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e>1;if(t=Sy[r])e=r+1;else return!0;if(e==n)return!1}}function Ay(t){return t>=127462&&t<=127487}const ky=8205;function bN(t,e,n=!0,r=!0){return(n?Cy:xN)(t,e,r)}function Cy(t,e,n){if(e==t.length)return e;e&&Ny(t.charCodeAt(e))&&Ty(t.charCodeAt(e-1))&&e--;let r=vf(t,e);for(e+=jy(r);e=0&&Ay(vf(t,c));)a++,c-=2;if(a%2==0)break;e+=2}else break}return e}function xN(t,e,n){for(;e>1;){let r=Cy(t,e-2,n);if(r=56320&&t<57344}function Ty(t){return t>=55296&&t<56320}function jy(t){return t<65536?1:2}class mt{lineAt(e){if(e<0||e>this.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,n,r){[e,n]=rl(this,e,n);let s=[];return this.decompose(0,e,s,2),r.length&&r.decompose(0,r.length,s,3),this.decompose(n,this.length,s,1),Hi.from(s,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=rl(this,e,n);let r=[];return this.decompose(e,n,r,0),Hi.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),s=new ma(this),a=new ma(e);for(let c=n,u=n;;){if(s.next(c),a.next(c),c=0,s.lineBreak!=a.lineBreak||s.done!=a.done||s.value!=a.value)return!1;if(u+=s.value.length,s.done||u>=r)return!0}}iter(e=1){return new ma(this,e)}iterRange(e,n=this.length){return new Oy(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let s=this.line(e).from;r=this.iterRange(s,Math.max(s,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new My(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?mt.empty:e.length<=32?new Vt(e):Hi.from(Vt.split(e,[]))}}class Vt extends mt{constructor(e,n=vN(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.text[a],u=s+c.length;if((n?r:u)>=e)return new wN(s,u,r,c);s=u+1,r++}}decompose(e,n,r,s){let a=e<=0&&n>=this.length?this:new Vt(Ey(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(s&1){let c=r.pop(),u=Ko(a.text,c.text.slice(),0,a.length);if(u.length<=32)r.push(new Vt(u,c.length+a.length));else{let f=u.length>>1;r.push(new Vt(u.slice(0,f)),new Vt(u.slice(f)))}}else r.push(a)}replace(e,n,r){if(!(r instanceof Vt))return super.replace(e,n,r);[e,n]=rl(this,e,n);let s=Ko(this.text,Ko(r.text,Ey(this.text,0,e)),n),a=this.length+r.length-(n-e);return s.length<=32?new Vt(s,a):Hi.from(Vt.split(s,[]),a)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;a<=n&&ce&&c&&(s+=r),ea&&(s+=u.slice(Math.max(0,e-a),n-a)),a=f+1}return s}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],s=-1;for(let a of e)r.push(a),s+=a.length+1,r.length==32&&(n.push(new Vt(r,s)),r=[],s=-1);return s>-1&&n.push(new Vt(r,s)),n}}class Hi extends mt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,s){for(let a=0;;a++){let c=this.children[a],u=s+c.length,f=r+c.lines-1;if((n?f:u)>=e)return c.lineInner(e,n,r,s);s=u+1,r=f+1}}decompose(e,n,r,s){for(let a=0,c=0;c<=n&&a=c){let h=s&((c<=e?1:0)|(f>=n?2:0));c>=e&&f<=n&&!h?r.push(u):u.decompose(e-c,n-c,r,h)}c=f+1}}replace(e,n,r){if([e,n]=rl(this,e,n),r.lines=a&&n<=u){let f=c.replace(e-a,n-a,r),h=this.lines-c.lines+f.lines;if(f.lines>4&&f.lines>h>>6){let g=this.children.slice();return g[s]=f,new Hi(g,this.length-(n-e)+r.length)}return super.replace(a,u,f)}a=u+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=` +`){[e,n]=rl(this,e,n);let s="";for(let a=0,c=0;ae&&a&&(s+=r),ec&&(s+=u.sliceString(e-c,n-c,r)),c=f+1}return s}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Hi))return 0;let r=0,[s,a,c,u]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;s+=n,a+=n){if(s==c||a==u)return r;let f=this.children[s],h=e.children[a];if(f!=h)return r+f.scanIdentical(h,n);r+=f.length+1}}static from(e,n=e.reduce((r,s)=>r+s.length+1,-1)){let r=0;for(let w of e)r+=w.lines;if(r<32){let w=[];for(let A of e)A.flatten(w);return new Vt(w,n)}let s=Math.max(32,r>>5),a=s<<1,c=s>>1,u=[],f=0,h=-1,g=[];function b(w){let A;if(w.lines>a&&w instanceof Hi)for(let C of w.children)b(C);else w.lines>c&&(f>c||!f)?(v(),u.push(w)):w instanceof Vt&&f&&(A=g[g.length-1])instanceof Vt&&w.lines+A.lines<=32?(f+=w.lines,h+=w.length+1,g[g.length-1]=new Vt(A.text.concat(w.text),A.length+1+w.length)):(f+w.lines>s&&v(),f+=w.lines,h+=w.length+1,g.push(w))}function v(){f!=0&&(u.push(g.length==1?g[0]:Hi.from(g,h)),h=-1,f=g.length=0)}for(let w of e)b(w);return v(),u.length==1?u[0]:new Hi(u,n)}}mt.empty=new Vt([""],0);function vN(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ko(t,e,n=0,r=1e9){for(let s=0,a=0,c=!0;a=n&&(f>r&&(u=u.slice(0,r-s)),s0?1:(e instanceof Vt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,s=this.nodes[r],a=this.offsets[r],c=a>>1,u=s instanceof Vt?s.text.length:s.children.length;if(c==(n>0?u:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((a&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=` +`,this;e--}else if(s instanceof Vt){let f=s.text[c+(n<0?-1:0)];if(this.offsets[r]+=n,f.length>Math.max(0,e))return this.value=e==0?f:n>0?f.slice(e):f.slice(0,f.length-e),this;e-=f.length}else{let f=s.children[c+(n<0?-1:0)];e>f.length?(e-=f.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(f),this.offsets.push(n>0?1:(f instanceof Vt?f.text.length:f.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class Oy{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ma(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:s}=this.cursor.next(e);return this.pos+=(s.length+e)*n,this.value=s.length<=r?s:n<0?s.slice(s.length-r):s.slice(0,r),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 My{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:s}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=s,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(mt.prototype[Symbol.iterator]=function(){return this.iter()},ma.prototype[Symbol.iterator]=Oy.prototype[Symbol.iterator]=My.prototype[Symbol.iterator]=function(){return this});class wN{constructor(e,n,r,s){this.from=e,this.to=n,this.number=r,this.text=s}get length(){return this.to-this.from}}function rl(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function kn(t,e,n=!0,r=!0){return bN(t,e,n,r)}function SN(t){return t>=56320&&t<57344}function AN(t){return t>=55296&&t<56320}function kN(t,e){let n=t.charCodeAt(e);if(!AN(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return SN(r)?(n-55296<<10)+(r-56320)+65536:n}function CN(t){return t<65536?1:2}const wf=/\r\n?|\n/;var Wn=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Wn||(Wn={}));class zi{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;ne)return a+(e-s);a+=u}else{if(r!=Wn.Simple&&h>=e&&(r==Wn.TrackDel&&se||r==Wn.TrackBefore&&se))return null;if(h>e||h==e&&n<0&&!u)return e==s||n<0?a:a+f;a+=f}s=h}if(e>s)throw new RangeError(`Position ${e} is out of range for changeset of length ${s}`);return a}touchesRange(e,n=e){for(let r=0,s=0;r=0&&s<=n&&u>=e)return sn?"cover":!0;s=u}return!1}toString(){let e="";for(let n=0;n=0?":"+s:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new zi(e)}static create(e){return new zi(e)}}class nn extends zi{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Sf(this,(n,r,s,a,c)=>e=e.replace(s,s+(r-n),c),!1),e}mapDesc(e,n=!1){return Af(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let s=0,a=0;s=0){n[s]=u,n[s+1]=c;let f=s>>1;for(;r.length0&&_r(r,n,a.text),a.forward(g),u+=g}let h=e[c++];for(;u>1].toJSON()))}return e}static of(e,n,r){let s=[],a=[],c=0,u=null;function f(g=!1){if(!g&&!s.length)return;cv||b<0||v>n)throw new RangeError(`Invalid change range ${b} to ${v} (in doc of length ${n})`);let A=w?typeof w=="string"?mt.of(w.split(r||wf)):w:mt.empty,C=A.length;if(b==v&&C==0)return;bc&&Cn(s,b-c,-1),Cn(s,v-b,C),_r(a,s,A),c=v}}return h(e),f(!u),u}static empty(e){return new nn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let s=0;su&&typeof c!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(a.length==1)n.push(a[0],0);else{for(;r.length=0&&n<=0&&n==t[s+1]?t[s]+=e:s>=0&&e==0&&t[s]==0?t[s+1]+=n:r?(t[s]+=e,t[s+1]+=n):t.push(e,n)}function _r(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r>1])),!(n||c==t.sections.length||t.sections[c+1]<0);)u=t.sections[c++],f=t.sections[c++];e(s,h,a,g,b),s=h,a=g}}}function Af(t,e,n,r=!1){let s=[],a=r?[]:null,c=new ga(t),u=new ga(e);for(let f=-1;;){if(c.done&&u.len||u.done&&c.len)throw new Error("Mismatched change set lengths");if(c.ins==-1&&u.ins==-1){let h=Math.min(c.len,u.len);Cn(s,h,-1),c.forward(h),u.forward(h)}else if(u.ins>=0&&(c.ins<0||f==c.i||c.off==0&&(u.len=0&&f=0){let h=0,g=c.len;for(;g;)if(u.ins==-1){let b=Math.min(g,u.len);h+=b,g-=b,u.forward(b)}else if(u.ins==0&&u.lenf||c.ins>=0&&c.len>f)&&(u||r.length>h),a.forward2(f),c.forward(f)}}}}class ga{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i>1;return n>=e.length?mt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?mt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class Lr{constructor(e,n,r,s){this.from=e,this.to=n,this.flags=r,this.goalColumn=s}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get undirectional(){return(this.flags&64)>0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}map(e,n=-1){let r,s;return this.empty?r=s=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),s=e.mapPos(this.to,-1)),r==this.from&&s==this.to?this:new Lr(r,s,this.flags,this.goalColumn)}extend(e,n=e,r=0){if(e<=this.anchor&&n>=this.anchor)return ke.range(e,n,void 0,void 0,r);let s=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ke.range(this.anchor,s,void 0,void 0,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ke.range(e.anchor,e.head)}static create(e,n,r,s){return new Lr(e,n,r,s)}}class ke{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ke.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;re.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ke(e.ranges.map(n=>Lr.fromJSON(n)),e.main)}static single(e,n=e){return new ke([ke.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,s=0;ss.from-a.from),n=e.indexOf(r);for(let s=1;sa.head?ke.range(f,u):ke.range(u,f))}}return new ke(e,n)}}function Dy(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let kf=0;class Ue{constructor(e,n,r,s,a){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=s,this.id=kf++,this.default=e([]),this.extensions=typeof a=="function"?a(this):a}get reader(){return this}static define(e={}){return new Ue(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Cf),!!e.static,e.enables)}of(e){return new Go([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Go(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Cf(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Go{constructor(e,n,r,s){this.dependencies=e,this.facet=n,this.type=r,this.value=s,this.id=kf++}dynamicSlot(e){var n;let r=this.value,s=this.facet.compareInput,a=this.id,c=e[a]>>1,u=this.type==2,f=!1,h=!1,g=[];for(let b of this.dependencies)b=="doc"?f=!0:b=="selection"?h=!0:(((n=e[b.id])!==null&&n!==void 0?n:1)&1)==0&&g.push(e[b.id]);return{create(b){return b.values[c]=r(b),1},update(b,v){if(f&&v.docChanged||h&&(v.docChanged||v.selection)||Nf(b,g)){let w=r(b);if(u?!_y(w,b.values[c],s):!s(w,b.values[c]))return b.values[c]=w,1}return 0},reconfigure:(b,v)=>{let w,A=v.config.address[a];if(A!=null){let C=Wo(v,A);if(this.dependencies.every(E=>E instanceof Ue?v.facet(E)===b.facet(E):E instanceof qr?v.field(E,!1)==b.field(E,!1):!0)||(u?_y(w=r(b),C,s):s(w=r(b),C)))return b.values[c]=C,0}else w=r(b);return b.values[c]=w,1}}}get extension(){return this}}function _y(t,e,n){if(t.length!=e.length)return!1;for(let r=0;rt[f.id]),s=n.map(f=>f.type),a=r.filter(f=>!(f&1)),c=t[e.id]>>1;function u(f){let h=[];for(let g=0;gr===s),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Xo).find(r=>r.field==this);return(n?.create||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,s)=>{let a=r.values[n],c=this.updateF(a,s);return this.compareF(a,c)?0:(r.values[n]=c,1)},reconfigure:(r,s)=>{let a=r.facet(Xo),c=s.facet(Xo),u;return(u=a.find(f=>f.field==this))&&u!=c.find(f=>f.field==this)?(r.values[n]=u.create(r),1):s.config.address[this.id]!=null?(r.values[n]=s.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Xo.of({field:this,create:e})]}get extension(){return this}}const Ns={lowest:4,low:3,default:2,high:1,highest:0};function ya(t){return e=>new Ly(e,t)}const Jo={highest:ya(Ns.highest),high:ya(Ns.high),default:ya(Ns.default),low:ya(Ns.low),lowest:ya(Ns.lowest)};class Ly{constructor(e,n){this.inner=e,this.prec=n}get extension(){return this}}class nr{of(e){return new Tf(this,e)}reconfigure(e){return nr.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Tf{constructor(e,n){this.compartment=e,this.inner=n}get extension(){return this}}class Qo{constructor(e,n,r,s,a,c){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=s,this.staticValues=a,this.facets=c,this.statusTemplate=[];this.statusTemplate.length>1]}static resolve(e,n,r){let s=[],a=Object.create(null),c=new Map;for(let v of TN(e,n,c))v instanceof qr?s.push(v):(a[v.facet.id]||(a[v.facet.id]=[])).push(v);let u=Object.create(null),f=[],h=[];for(let v of s)u[v.id]=h.length<<1,h.push(w=>v.slot(w));let g=r?.config.facets;for(let v in a){let w=a[v],A=w[0].facet,C=g&&g[v]||[];if(w.every(E=>E.type==0))if(u[A.id]=f.length<<1|1,Cf(C,w))f.push(r.facet(A));else{let E=A.combine(w.map(D=>D.value));f.push(r&&A.compare(E,r.facet(A))?r.facet(A):E)}else{for(let E of w)E.type==0?(u[E.id]=f.length<<1|1,f.push(E.value)):(u[E.id]=h.length<<1,h.push(D=>E.dynamicSlot(D)));u[A.id]=h.length<<1,h.push(E=>NN(E,A,w))}}let b=h.map(v=>v(u));return new Qo(e,c,b,u,f,a)}}function TN(t,e,n){let r=[[],[],[],[],[]],s=new Map;function a(c,u){let f=s.get(c);if(f!=null){if(f<=u)return;let h=r[f].indexOf(c);h>-1&&r[f].splice(h,1),c instanceof Tf&&n.delete(c.compartment)}if(s.set(c,u),Array.isArray(c))for(let h of c)a(h,u);else if(c instanceof Tf){if(n.has(c.compartment))throw new RangeError("Duplicate use of compartment in extensions");let h=e.get(c.compartment)||c.inner;n.set(c.compartment,h),a(h,u)}else if(c instanceof Ly)a(c.inner,c.prec);else if(c instanceof qr)r[u].push(c),c.provides&&a(c.provides,u);else if(c instanceof Go)r[u].push(c),c.facet.extensions&&a(c.facet.extensions,Ns.default);else{let h=c.extension;if(!h)throw new Error(`Unrecognized extension value in extension set (${c}).`);if(h==c)throw new Error(`Unrecognized extension value in extension set (${c}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);a(h,u)}}return a(t,Ns.default),r.reduce((c,u)=>c.concat(u))}function ba(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let s=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|s}function Wo(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const qy=Ue.define(),jf=Ue.define({combine:t=>t.some(e=>e),static:!0}),By=Ue.define({combine:t=>t.length?t[0]:void 0,static:!0}),$y=Ue.define(),Iy=Ue.define(),Hy=Ue.define(),zy=Ue.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new jN}}class jN{of(e){return new Br(this,e)}}class EN{constructor(e){this.map=e}of(e){return new Ft(this,e)}}class Ft{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Ft(this.type,n)}is(e){return this.type==e}static define(e={}){return new EN(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let s of e){let a=s.map(n);a&&r.push(a)}return r}}Ft.reconfigure=Ft.define(),Ft.appendConfig=Ft.define();class rn{constructor(e,n,r,s,a,c){this.startState=e,this.changes=n,this.selection=r,this.effects=s,this.annotations=a,this.scrollIntoView=c,this._doc=null,this._state=null,r&&Dy(r,n.newLength),a.some(u=>u.type==rn.time)||(this.annotations=a.concat(rn.time.of(Date.now())))}static create(e,n,r,s,a,c){return new rn(e,n,r,s,a,c)}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 n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(rn.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}rn.time=Br.define(),rn.userEvent=Br.define(),rn.addToHistory=Br.define(),rn.remote=Br.define();function ON(t,e){let n=[];for(let r=0,s=0;;){let a,c;if(r=t[r]))a=t[r++],c=t[r++];else if(s=0;s--){let a=r[s](t);a instanceof rn?t=a:Array.isArray(a)&&a.length==1&&a[0]instanceof rn?t=a[0]:t=Vy(e,sl(a),!1)}return t}function RN(t){let e=t.startState,n=e.facet(Hy),r=t;for(let s=n.length-1;s>=0;s--){let a=n[s](t);a&&Object.keys(a).length&&(r=Uy(r,Ef(e,a,t.changes.newLength),!0))}return r==t?t:rn.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const DN=[];function sl(t){return t==null?DN:Array.isArray(t)?t:[t]}var ir=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(ir||(ir={}));const _N=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Of;try{Of=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function LN(t){if(Of)return Of.test(t);for(let e=0;e"€"&&(n.toUpperCase()!=n.toLowerCase()||_N.test(n)))return!0}return!1}function qN(t){return e=>{if(!/\S/.test(e))return ir.Space;if(LN(e))return ir.Word;for(let n=0;n-1)return ir.Word;return ir.Other}}class St{constructor(e,n,r,s,a,c){this.config=e,this.doc=n,this.selection=r,this.values=s,this.status=e.statusTemplate.slice(),this.computeSlot=a,c&&(c._state=this);for(let u=0;us.set(h,f)),n=null),s.set(u.value.compartment,u.value.extension)):u.is(Ft.reconfigure)?(n=null,r=u.value):u.is(Ft.appendConfig)&&(n=null,r=sl(r).concat(u.value));let a;n?a=e.startState.values.slice():(n=Qo.resolve(r,s,this),a=new St(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(f,h)=>h.reconfigure(f,this),null).values);let c=e.startState.facet(jf)?e.newSelection:e.newSelection.asSingle();new St(n,e.newDoc,c,a,(u,f)=>f.update(u,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ke.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),s=this.changes(r.changes),a=[r.range],c=sl(r.effects);for(let u=1;uc.spec.fromJSON(u,f)))}}return St.create({doc:e.doc,selection:ke.fromJSON(e.selection),extensions:n.extensions?s.concat([n.extensions]):s})}static create(e={}){let n=Qo.resolve(e.extensions||[],new Map),r=e.doc instanceof mt?e.doc:mt.of((e.doc||"").split(n.staticFacet(St.lineSeparator)||wf)),s=e.selection?e.selection instanceof ke?e.selection:ke.single(e.selection.anchor,e.selection.head):ke.single(0);return Dy(s,r.length),n.staticFacet(jf)||(s=s.asSingle()),new St(n,r,s,n.dynamicSlots.map(()=>null),(a,c)=>c.create(a),null)}get tabSize(){return this.facet(St.tabSize)}get lineBreak(){return this.facet(St.lineSeparator)||` +`}get readOnly(){return this.facet(zy)}phrase(e,...n){for(let r of this.facet(St.phrases))if(Object.prototype.hasOwnProperty.call(r,e)){e=r[e];break}return n.length&&(e=e.replace(/\$(\$|\d*)/g,(r,s)=>{if(s=="$")return"$";let a=+(s||1);return!a||a>n.length?r:n[a-1]})),e}languageDataAt(e,n,r=-1){let s=[];for(let a of this.facet(qy))for(let c of a(this,n,r))Object.prototype.hasOwnProperty.call(c,e)&&s.push(c[e]);return s}charCategorizer(e){let n=this.languageDataAt("wordChars",e);return qN(n.length?n[0]:"")}wordAt(e){let{text:n,from:r,length:s}=this.doc.lineAt(e),a=this.charCategorizer(e),c=e-r,u=e-r;for(;c>0;){let f=kn(n,c,!1);if(a(n.slice(f,c))!=ir.Word)break;c=f}for(;ut.length?t[0]:4}),St.lineSeparator=By,St.readOnly=zy,St.phrases=Ue.define({compare(t,e){let n=Object.keys(t),r=Object.keys(e);return n.length==r.length&&n.every(s=>t[s]==e[s])}}),St.languageData=qy,St.changeFilter=$y,St.transactionFilter=Iy,St.transactionExtender=Hy,nr.reconfigure=Ft.define();function Mf(t,e,n={}){let r={};for(let s of t)for(let a of Object.keys(s)){let c=s[a],u=r[a];if(u===void 0)r[a]=c;else if(!(u===c||c===void 0))if(Object.hasOwnProperty.call(n,a))r[a]=n[a](u,c);else throw new Error("Config merge conflict for field "+a)}for(let s in e)r[s]===void 0&&(r[s]=e[s]);return r}class Ts{eq(e){return this==e}range(e,n=e){return Df.create(e,n,this)}}Ts.prototype.startSide=Ts.prototype.endSide=0,Ts.prototype.point=!1,Ts.prototype.mapMode=Wn.TrackDel;function Rf(t,e){return t==e||t.constructor==e.constructor&&t.eq(e)}let Df=class jA{constructor(e,n,r){this.from=e,this.to=n,this.value=r}static create(e,n,r){return new jA(e,n,r)}};function _f(t,e){return t.from-e.from||t.value.startSide-e.value.startSide}class Lf{constructor(e,n,r,s){this.from=e,this.to=n,this.value=r,this.maxPoint=s}get length(){return ll(this.to)}findIndex(e,n,r,s=0){let a=r?this.to:this.from;for(let c=s,u=a.length;;){if(c==u)return c;let f=c+u>>1,h=a[f]-e||(r?this.value[f].endSide:this.value[f].startSide)-n;if(f==c)return h>=0?c:u;h>=0?u=f:c=f+1}}between(e,n,r,s){for(let a=this.findIndex(n,-1e9,!0),c=this.findIndex(r,1e9,!1,a);aE||C==E&&v.startSide>0&&v.endSide<=0)continue;if(!((E-C||v.endSide-v.startSide)<0))if(h<0&&(h=C),v.point&&(g=Math.max(g,E-C)),(C-r||v.startSide-s)>=0)c.push(v),u.push(C-h),f.push(E-h),r=E,s=v.endSide;else{if(C==E)for(let D=c.length;D>0;D--){if((C-(f[D-1]+h)||v.startSide-c[D-1].endSide)>=0){c.splice(D,0,v),u.splice(D,0,C-h),f.splice(D,0,E-h);continue e}if((C-(u[D-1]+h)||v.endSide-c[D-1].startSide)>0)break}a(C,E,v)}}return{mapped:c.length?new Lf(u,f,c,g):null,pos:h}}}class pt{constructor(e,n,r,s){this.chunkPos=e,this.chunk=n,this.nextLayer=r,this.maxPoint=s}static create(e,n,r,s){return new pt(e,n,r,s)}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 n of this.chunk)e+=n.value.length;return e}chunkEnd(e){return this.chunkPos[e]+this.chunk[e].length}update(e){let{add:n=[],sort:r=!1,filterFrom:s=0,filterTo:a=this.length}=e,c=e.filter;if(n.length==0&&!c)return this;if(r&&(n=n.slice().sort(_f)),this.isEmpty)return n.length?pt.of(n):this;let u=new Py(this,null,-1).goto(0),f=0,h=[],g=new xa;for(;u.value||f=0){let b=n[f++];g.addInner(b.from,b.to,b.value,!1)||h.push(b)}else u.rangeIndex==1&&u.chunkIndexthis.chunkEnd(u.chunkIndex)||au.to||a{a||(a=new xa),a.addRange(f,h,g,!1)};for(let f=0;f=a&&e<=a+c.length&&c.between(a,e-a,n-a,r)===!1)return}this.nextLayer.between(e,n,r)}}iter(e=0){return va.from([this]).goto(e)}get isEmpty(){return this.nextLayer==this}static iter(e,n=0){return va.from(e).goto(n)}static compare(e,n,r,s,a=-1){let c=e.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),u=n.filter(b=>b.maxPoint>0||!b.isEmpty&&b.maxPoint>=a),f=Fy(c,u,r),h=new wa(c,f,a),g=new wa(u,f,a);r.iterGaps((b,v,w)=>Yy(h,b,g,v,w,s)),r.empty&&r.length==0&&Yy(h,0,g,0,0,s)}static eq(e,n,r=0,s){s==null&&(s=999999999);let a=e.filter(g=>!g.isEmpty&&n.indexOf(g)<0),c=n.filter(g=>!g.isEmpty&&e.indexOf(g)<0);if(a.length!=c.length)return!1;if(!a.length)return!0;let u=Fy(a,c),f=new wa(a,u,0).goto(r),h=new wa(c,u,0).goto(r);for(;;){if(f.to!=h.to||!Bf(f.active,h.active)||f.point&&(!h.point||!Rf(f.point,h.point)))return!1;if(f.to>s)return!0;f.next(),h.next()}}static spans(e,n,r,s,a=-1){let c=new wa(e,null,a).goto(n),u=n,f=c.openStart;for(;;){let h=Math.min(c.to,r);if(c.point){let g=c.activeForPoint(c.to),b=c.pointFromu&&(s.span(u,h,c.active,f),f=c.openEnd(h));if(c.to>r)return f+(c.point&&c.to>r?1:0);u=c.to,c.next()}}static of(e,n=!1){let r=new xa;for(let s of e instanceof Df?[e]:n?BN(e):e)r.add(s.from,s.to,s.value);return r.finish()}static join(e){if(!e.length)return pt.empty;let n=ll(e);for(let r=e.length-2;r>=0;r--)for(let s=e[r];s!=pt.empty;s=s.nextLayer)n=new pt(s.chunkPos,s.chunk,n,Math.max(s.maxPoint,n.maxPoint));return n}}pt.empty=new pt([],[],null,-1);function ll(t){return t[t.length-1]}function BN(t){if(t.length>1)for(let e=t[0],n=1;n0)return t.slice().sort(_f);e=r}return t}pt.empty.nextLayer=pt.empty;class xa{finishChunk(e){this.chunks.push(new Lf(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=[])}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}add(e,n,r){this.addRange(e,n,r,!0)}addRange(e,n,r,s){this.addInner(e,n,r,s)||(this.nextLayer||(this.nextLayer=new xa)).addRange(e,n,r,s)}addInner(e,n,r,s){let a=e-this.lastTo||r.startSide-this.last.endSide;if(s&&a<=0&&(e-this.lastFrom||r.startSide-this.last.startSide)<0)throw new Error("Ranges must be added sorted by `from` position and `startSide`");return a<0?!1:(this.from.length==250&&this.finishChunk(!0),this.chunkStart<0&&(this.chunkStart=e),this.from.push(e-this.chunkStart),this.to.push(n-this.chunkStart),this.last=r,this.lastFrom=e,this.lastTo=n,this.value.push(r),r.point&&(this.maxPoint=Math.max(this.maxPoint,n-e)),!0)}addChunk(e,n){if((e-this.lastTo||n.value[0].startSide-this.last.endSide)<0)return!1;this.from.length&&this.finishChunk(!0),this.setMaxPoint=Math.max(this.setMaxPoint,n.maxPoint),this.chunks.push(n),this.chunkPos.push(e);let r=n.value.length-1;return this.last=n.value[r],this.lastFrom=n.from[r]+e,this.lastTo=n.to[r]+e,!0}finish(){return this.finishInner(pt.empty)}finishInner(e){if(this.from.length&&this.finishChunk(!1),this.chunks.length==0)return e;let n=pt.create(this.chunkPos,this.chunks,this.nextLayer?this.nextLayer.finishInner(e):e,this.setMaxPoint);return this.from=null,n}}function Fy(t,e,n){let r=new Map;for(let a of t)for(let c=0;c=this.minPoint)break}}setRangeIndex(e){if(e==this.layer.chunk[this.chunkIndex].value.length){if(this.chunkIndex++,this.skip)for(;this.chunkIndex=r&&s.push(new Py(c,n,r,a));return s.length==1?s[0]:new va(s)}get startSide(){return this.value?this.value.startSide:0}goto(e,n=-1e9){for(let r of this.heap)r.goto(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);return this.next(),this}forward(e,n){for(let r of this.heap)r.forward(e,n);for(let r=this.heap.length>>1;r>=0;r--)qf(this.heap,r);(this.to-e||this.value.endSide-n)<0&&this.next()}next(){if(this.heap.length==0)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(),qf(this.heap,0)}}}function qf(t,e){for(let n=t[e];;){let r=(e<<1)+1;if(r>=t.length)break;let s=t[r];if(r+1=0&&(s=t[r+1],r++),n.compare(s)<0)break;t[r]=n,t[e]=s,e=r}}class wa{constructor(e,n,r){this.minPoint=r,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=va.from(e,n,r)}goto(e,n=-1e9){return this.cursor.goto(e,n),this.active.length=this.activeTo.length=this.activeRank.length=0,this.minActive=-1,this.to=e,this.endSide=n,this.openStart=-1,this.next(),this}forward(e,n){for(;this.minActive>-1&&(this.activeTo[this.minActive]-e||this.active[this.minActive].endSide-n)<0;)this.removeActive(this.minActive);this.cursor.forward(e,n)}removeActive(e){Zo(this.active,e),Zo(this.activeTo,e),Zo(this.activeRank,e),this.minActive=Ky(this.active,this.activeTo)}addActive(e){let n=0,{value:r,to:s,rank:a}=this.cursor;for(;n0;)n++;ec(this.active,n,r),ec(this.activeTo,n,s),ec(this.activeRank,n,a),e&&ec(e,n,this.cursor.from),this.minActive=Ky(this.active,this.activeTo)}next(){let e=this.to,n=this.point;this.point=null;let r=this.openStart<0?[]:null;for(;;){let s=this.minActive;if(s>-1&&(this.activeTo[s]-this.cursor.from||this.active[s].endSide-this.cursor.startSide)<0){if(this.activeTo[s]>e){this.to=this.activeTo[s],this.endSide=this.active[s].endSide;break}this.removeActive(s),r&&Zo(r,s)}else if(this.cursor.value)if(this.cursor.from>e){this.to=this.cursor.from,this.endSide=this.cursor.startSide;break}else{let a=this.cursor.value;if(!a.point)this.addActive(r),this.cursor.next();else if(n&&this.cursor.to==this.to&&this.cursor.from=0&&r[s]=0&&!(this.activeRank[r]e||this.activeTo[r]==e&&this.active[r].endSide>=this.point.endSide)&&n.push(this.active[r]);return n.reverse()}openEnd(e){let n=0;for(let r=this.activeTo.length-1;r>=0&&this.activeTo[r]>e;r--)n++;return n}}function Yy(t,e,n,r,s,a){t.goto(e),n.goto(r);let c=r+s,u=r,f=r-e,h=!!a.boundChange;for(let g=!1;;){let b=t.to+f-n.to,v=b||t.endSide-n.endSide,w=v<0?t.to+f:n.to,A=Math.min(w,c);if(t.point||n.point?(t.point&&n.point&&Rf(t.point,n.point)&&Bf(t.activeForPoint(t.to),n.activeForPoint(n.to))||a.comparePoint(u,A,t.point,n.point),g=!1):(g&&a.boundChange(u),A>u&&!Bf(t.active,n.active)&&a.compareRange(u,A,t.active,n.active),h&&Ac)break;u=w,v<=0&&t.next(),v>=0&&n.next()}}function Bf(t,e){if(t.length!=e.length)return!1;for(let n=0;n=e;r--)t[r+1]=t[r];t[e]=n}function Ky(t,e){let n=-1,r=1e9;for(let s=0;s=e)return s;if(s==t.length)break;a+=t.charCodeAt(s)==9?n-a%n:1,s=kn(t,s)}return t.length}const $f="ͼ",Gy=typeof Symbol>"u"?"__"+$f:Symbol.for($f),If=typeof Symbol>"u"?"__styleSet"+Math.floor(Math.random()*1e8):Symbol("styleSet"),Xy=typeof globalThis<"u"?globalThis:typeof window<"u"?window:{};class al{constructor(e,n){this.rules=[];let{finish:r}=n||{};function s(c){return/^@/.test(c)?[c]:c.split(/,\s*/)}function a(c,u,f,h){let g=[],b=/^@(\w+)\b/.exec(c[0]),v=b&&b[1]=="keyframes";if(b&&u==null)return f.push(c[0]+";");for(let w in u){let A=u[w];if(/&/.test(w))a(w.split(/,\s*/).map(C=>c.map(E=>C.replace(/&/,E))).reduce((C,E)=>C.concat(E)),A,f);else if(A&&typeof A=="object"){if(!b)throw new RangeError("The value of a property ("+w+") should be a primitive value.");a(s(w),A,g,v)}else A!=null&&g.push(w.replace(/_.*/,"").replace(/[A-Z]/g,C=>"-"+C.toLowerCase())+": "+A+";")}(g.length||v)&&f.push((r&&!b&&!h?c.map(r):c).join(", ")+" {"+g.join(" ")+"}")}for(let c in e)a(s(c),e[c],this.rules)}getRules(){return this.rules.join(` `)}static newName(){let e=Xy[Gy]||1;return Xy[Gy]=e+1,$f+e.toString(36)}static mount(e,n,r){let s=e[If],a=r&&r.nonce;s?a&&s.setNonce(a):s=new IN(e,a),s.mount(Array.isArray(n)?n:[n],e)}}let Jy=new Map;class IN{constructor(e,n){let r=e.ownerDocument||e,s=r.defaultView;if(!e.head&&e.adoptedStyleSheets&&s.CSSStyleSheet){let a=Jy.get(r);if(a)return e[If]=a;this.sheet=new s.CSSStyleSheet,Jy.set(r,this)}else this.styleTag=r.createElement("style"),n&&this.styleTag.setAttribute("nonce",n);this.modules=[],e[If]=this}mount(e,n){let r=this.sheet,s=0,a=0;for(let c=0;c-1&&(this.modules.splice(f,1),a--,f=-1),f==-1){if(this.modules.splice(a++,0,u),r)for(let h=0;h",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Me={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return mt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=mt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return mt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let E=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,E)),v={left:E.left,right:E.left+g.clientWidth*A,top:E.top,bottom:E.top+g.clientHeight*C}}let O=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+O&&(O=e.right-v.right+a)):e.right>v.right-a&&(O=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Me.safari&&Me.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let O=Ui[C+2],D=O&2?s:O&4?O&1?a:s:0;D&&(jt[b]=jt[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=jt[b])==2||A==1){let C=A==s;f=C?0:1;for(let O=u-3;O>=0;O-=3){let D=Ui[O+2];if(D&2)break;if(C)Ui[O+2]|=2;else{if(D&4)break;Ui[O+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==O&&(A=n[--C].from,O=C?n[C-1].to:t),jt[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let O=C.direction==Os!=!(w%2);Wf(t,O?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?jt[A]!=u:jt[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=jt[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let O=C.from,D=h;;){if(O==e)break e;if(D&&a[D-1].to==O)O=a[--D].from;else{if(jt[O-1]==u)break e;break}}if(v)v.push(C);else{C.tojt.length;)jt[jt.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(Ae.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return mt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Me.chrome||Me.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Me.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Me.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=mt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Me.ie||Me.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Me.chrome||Me.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Me.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Me.android&&Me.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Me.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],O=v+C.length,D=C.dom.getBoundingClientRect(),{height:E}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)O>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(E+h),h=0,c)){let j=C.dom.lastChild,M=j?sc(j):[];if(M.length){let _=M[M.length-1],q=f?_.right-D.left:D.right-_.left;q>u&&(u=q,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=O)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=O+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(mt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return Ae.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return Ae.cursor(f,n?-1:1)}return Ae.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` -`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return Ae.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,O=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:E{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:Ae.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let E=1;E=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let O=n(C),D=0;if(O)for(let E=0;E1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let M=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(wt.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Me.ios||Me.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(Ae.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=Ae.create([Ae.cursor(h,w)])}else this.newSel=Ae.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Me.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:gt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Me.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:gt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Me.mac||Me.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:gt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Me.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` - `&&t.lineWrapping&&(r&&(r=Ae.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:gt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Me.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Me.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:Ae.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,O=C-g.length;if(t.state.sliceDoc(O,C)!=g||C>=b.from&&O<=b.to)return{range:A};let D=s.changes({from:O,to:C,insert:e.insert}),E=A.to-a.to;return{changes:D,range:h?Ae.range(Math.max(0,h.anchor+E),Math.max(0,h.head+E)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?Ae.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Me.safari&&e.contentDOM.addEventListener("input",()=>null),Me.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Me.android&&Me.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Me.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Me.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Me.safari&&!Me.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(wt.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Me.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Me.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Me.ie&&Me.ie_version<15||Me.ios&&Me.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:Ae.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:Ae.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Me.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return Ae.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):Ae.create([g])}}}function ej(t,e){for(let n=0;n=e)return Ae.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=Ae.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Me.chrome&&Me.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Me.chrome&&Me.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Me.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Me.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=gt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Mt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Mt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Mt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Mt.ByPosNoHeight?Mt.ByPosNoHeight:Mt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Mt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:q}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||q>.005&&Math.abs(this.scaleY-q)>.005)&&(this.scaleX=_,this.scaleY=q,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),O=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let E=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(E!=this.inView&&(this.inView=E,E&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:q,charWidth:R,textHeight:J}=e.docView.measureTextSize();c=q>0&&s.refresh(a,q,R,J,Math.max(5,j/R),_),c&&(e.docView.minWidth=0,h|=16)}O>0&&D>0?g=Math.max(O,D):O<0&&D<0&&(g=Math.min(O,D)),ax();for(let q of this.viewports){let R=q.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(q);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,gt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(q.from,R))}ml&&(h|=2)}let M=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return M&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||M)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Mt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Mt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Mt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromE));if(!O){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(Ae.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),E=r||D<2e6?D:2e6;O=new mh(g,b,D,E)}u.push(O)},h=g=>{if(g.length2e6)for(let q of e)q.from>=g.from&&q.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];mt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Mt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Mt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return mt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(mt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Mt.ByPos,e,0,0).top,g=n.lineAt(f,Mt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Me.ie&&Me.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Me.ie&&Me.ie_version<=11||Me.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Me.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Me.chrome&&Me.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Me.ie&&Me.ie_version<=11||Me.android&&Me.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Me.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=Ae.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:gt.of(r.text.slice(g.from,g.toB).split(` -`))};if((Me.mac||Me.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:gt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,Ae.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Qe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||wt.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(wt.phrases)!=this.state.facet(wt.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Qe.cursorScrollMargin);b=new ul(w.empty?w:Ae.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Me.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Qe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Qe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return Ae.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?Ae.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(Ae.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Qe.styleModule=Ma,Qe.inputHandler=Sb,Qe.clipboardInputFilter=eh,Qe.clipboardOutputFilter=th,Qe.scrollHandler=Nb,Qe.focusChangeEffect=Ab,Qe.perLineTextDirection=kb,Qe.exceptionSink=wb,Qe.updateListener=Zf,Qe.editable=sr,Qe.mouseSelectionStyle=vb,Qe.dragMovesSelection=xb,Qe.clickAddsSelectionRange=bb,Qe.decorations=cc,Qe.blockWrappers=Eb,Qe.outerDecorations=rh,Qe.atomicRanges=Oa,Qe.bidiIsolatedRanges=Ob,Qe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Qe.scrollMargins=Rb,Qe.darkTheme=yh,Qe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Qe.contentAttributes=ih,Qe.editorAttributes=jb,Qe.lineWrapping=Qe.contentAttributes.of({class:"cm-lineWrapping"}),Qe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let M=Hr={view:j,prefix:E,scope:c};return setTimeout(()=>{Hr==M&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let O=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&O.run.push(f),h&&(O.preventDefault=!0),g&&(O.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=O=>{if(O){for(let D of O.run)if(!b.has(D)&&(b.add(D),D(n)))return O.stopPropagation&&(g=!0),!0;O.preventDefault&&(O.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,O=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),O&&(t.lineWrapping||A.widgetLineBreaks)&&(O=Ax(t,s,-1,O)),C&&O&&C.from==O.from&&C.to==O.to)return E(j(n.from,n.to,C));{let _=C?j(n.from,null,C):M(w,!1),q=O?j(null,n.to,O):M(A,!0),R=[];return(C||w).to<(O||A).from-(C&&O?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2W&&me.from=L)break;ve>fe&&K(Math.max(ue,fe),_==null&&ue<=W,Math.min(ve,L),q==null&&ve>=ye,oe.dir)}if(fe=Q.to+1,fe>=L)break}return B.length==0&&K(W,_==null,ye,q==null,t.textDirection),{top:J,bottom:U,horizontal:B}}function M(_,q){let R=u.top+(q?_.top:_.bottom);return{top:R,bottom:R,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Me.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Me.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:Ae.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Me.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",Ae.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",Ae.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Me.gecko&&Me.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Qe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=mt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!mt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Qe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=mt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!mt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return mt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class yt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}yt.closedBy=new yt({deserialize:t=>t.split(" ")}),yt.openedBy=new yt({deserialize:t=>t.split(" ")}),yt.group=new yt({deserialize:t=>t.split(" ")}),yt.isolate=new yt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),yt.contextHash=new yt({perNode:!0}),yt.lookAhead=new yt({perNode:!0}),yt.mounted=new yt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[yt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(yt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(yt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,q,R,J,U,B){let{id:K,start:W,end:ye,size:me}=u,fe=g,L=h;if(me<0)if(u.next(),me==-1){let T=a[K];R.push(T),J.push(W-_);return}else if(me==-3){h=K;return}else if(me==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${me}`);let Q=f[K],oe,ue,ve=W-_;if(ye-W<=s&&(ue=O(u.pos-q,U))){let T=new Uint16Array(ue.size-ue.skip),z=u.pos-ue.size,he=T.length;for(;u.pos>z;)he=D(ue.start,T,he);oe=new Ur(T,ye-ue.start,r),ve=ue.start-_}else{let T=u.pos-me;u.next();let z=[],he=[],ne=K>=c?K:-1,ke=0,_e=ye;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=_e-s&&(A(z,he,W,ke,u.end,_e,ne,fe,L),ke=z.length,_e=u.end),u.next()):B>2500?v(W,T,z,he):b(W,T,z,he,ne,B+1);if(ne>=0&&ke>0&&ke-1&&ke>0){let $e=w(Q,L);oe=Oh(Q,z,he,0,z.length,0,ye-W,$e,$e)}else oe=C(Q,z,he,ye-W,fe-ye,L)}R.push(oe),J.push(ve)}function v(_,q,R,J){let U=[],B=0,K=-1;for(;u.pos>q;){let{id:W,start:ye,end:me,size:fe}=u;if(fe>4)u.next();else{if(K>-1&&ye=0;me-=3)W[fe++]=U[me],W[fe++]=U[me+1]-ye,W[fe++]=U[me+2]-ye,W[fe++]=fe;R.push(new Ur(W,U[2]-ye,r)),J.push(ye-_)}}function w(_,q){return(R,J,U)=>{let B=0,K=R.length-1,W,ye;if(K>=0&&(W=R[K])instanceof pn){if(!K&&W.type==_&&W.length==U)return W;(ye=W.prop(yt.lookAhead))&&(B=J[K]+W.length+ye)}return C(_,R,J,U,B,q)}}function A(_,q,R,J,U,B,K,W,ye){let me=[],fe=[];for(;_.length>J;)me.push(_.pop()),fe.push(q.pop()+R-U);_.push(C(r.types[K],me,fe,B-U,W-B,ye)),q.push(U-R)}function C(_,q,R,J,U,B,K){if(B){let W=[yt.contextHash,B];K=K?[W].concat(K):[W]}if(U>25){let W=[yt.lookAhead,U];K=K?[W].concat(K):[W]}return new pn(_,q,R,J,K)}function O(_,q){let R=u.fork(),J=0,U=0,B=0,K=R.end-s,W={size:0,start:0,skip:0};e:for(let ye=R.pos-_;R.pos>ye;){let me=R.size;if(R.id==q&&me>=0){W.size=J,W.start=U,W.skip=B,B+=4,J+=4,R.next();continue}let fe=R.pos-me;if(me<0||fe=c?4:0,Q=R.start;for(R.next();R.pos>fe;){if(R.size<0)if(R.size==-3||R.size==-4)L+=4;else break e;else R.id>=c&&(L+=4);R.next()}U=Q,J+=me,B+=L}return(q<0||J==_)&&(W.size=J,W.start=U,W.skip=B),W.size>4?W:void 0}function D(_,q,R){let{id:J,start:U,end:B,size:K}=u;if(u.next(),K>=0&&J4){let ye=u.pos-(K-4);for(;u.pos>ye;)R=D(_,q,R)}q[--R]=W,q[--R]=B-_,q[--R]=U-_,q[--R]=J}else K==-3?h=J:K==-4&&(g=J);return R}let E=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,E,j,-1,0);let M=(e=t.length)!==null&&e!==void 0?e:E.length?j[0]+E[0].length:0;return new pn(f[t.topID],E.reverse(),j.reverse(),M)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;q+=R}if(j==M+1){if(q>g){let R=A[M];w(R.children,R.positions,0,R.children.length,C[M]+E);continue}b.push(A[M])}else{let R=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,M,j,_,R,null,f))}v.push(_+E-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new yt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new yt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new yt,fE=new yt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,wt.prototype.hasOwnProperty("tree")||Object.defineProperty(wt.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),wt.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(yt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Qe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new yt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(yt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new yt;function Bh(t,e,n){let r=t.prop(e<0?yt.openedBy:yt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,O=n>0?w.length:-1;C!=O;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Qe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&Ae.fromJSON(e.startSelection),e.selectionsAfter.map(Ae.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?yt.closedBy:yt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,Ae.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=Ae.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>Ae.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=Ae.range(s.head,s.anchor));let a=n(s);return Ae.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>Ae.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>Ae.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>Ae.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:Ae.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return Ae.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,Ae.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=Ae.create([n.main]):n.main.empty||(r=Ae.create([Ae.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:Ae.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:gt.of(["",""])},range:Ae.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:Ae.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(Ae.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(Ae.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:Ae.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(yt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:Ae.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Qe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` -`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},O)=>{const D=I.useRef(null),E=I.useRef(null),j=I.useRef(n),M=I.useRef(C),_=I.useRef(A),q=I.useRef(!1),R=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),J=I.useMemo(()=>new nr,[]),U=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),W=I.useMemo(()=>new nr,[]);j.current=n,M.current=C,_.current=A,I.useImperativeHandle(O,()=>({focus:()=>E.current?.focus(),getSelection:()=>{const Q=E.current?.state.selection.main;return Q?{from:Q.from,to:Q.to}:{from:0,to:0}},setSelection:(Q,oe=Q)=>{const ue=E.current;if(!ue)return;const ve=ue.state.doc.length,T=Math.max(0,Math.min(Q,ve)),z=Math.max(0,Math.min(oe,ve));ue.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),ue.focus(),M.current?.(T)},coordsAtPos:Q=>{const oe=E.current;if(!oe)return null;const ue=Math.max(0,Math.min(Q,oe.state.doc.length)),ve=oe.coordsAtPos(ue);return ve?{left:ve.left,right:ve.right,top:ve.top,bottom:ve.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||E.current)return;const Q=R.current,oe=wt.create({doc:Q.value,extensions:[zE(),Dj(),J.of(zv(Q.theme)),U.of(Q.wrap?Qe.lineWrapping:[]),B.of(Q.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(Q.autoIndent)),W.of(Qe.contentAttributes.of(Hv(Q))),Jo.highest(Qe.domEventHandlers({keydown:ve=>(_.current?.(ve),ve.defaultPrevented)})),Qe.updateListener.of(ve=>{ve.docChanged&&!q.current&&j.current(ve.state.doc.toString()),(ve.selectionSet||ve.docChanged)&&M.current?.(ve.state.selection.main.head)})]}),ue=new Qe({state:oe,parent:D.current});return E.current=ue,()=>{ue.destroy(),E.current=null}},[W,B,K,J,U]),I.useEffect(()=>{const Q=E.current;if(!Q||Q.state.doc.toString()===e)return;const oe=Q.state.selection.main;q.current=!0,Q.dispatch({changes:{from:0,to:Q.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),q.current=!1},[e]),I.useEffect(()=>{E.current?.dispatch({effects:J.reconfigure(zv(s))})},[s,J]),I.useEffect(()=>{E.current?.dispatch({effects:U.reconfigure(f?Qe.lineWrapping:[])}),E.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,U]),I.useEffect(()=>{E.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{E.current?.dispatch({effects:W.reconfigure(Qe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,W,u]);const ye=Math.max(1,e.split(` -`).length),fe=Math.min(c,Math.max(a,ye))*24+16,L=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${L?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:fe},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,O)=>O===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;s",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},HN=typeof navigator<"u"&&/Mac/.test(navigator.platform),zN=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),dn=0;dn<10;dn++)$r[48+dn]=$r[96+dn]=String(dn);for(var dn=1;dn<=24;dn++)$r[dn+111]="F"+dn;for(var dn=65;dn<=90;dn++)$r[dn]=String.fromCharCode(dn+32),Sa[dn]=String.fromCharCode(dn);for(var Hf in $r)Sa.hasOwnProperty(Hf)||(Sa[Hf]=$r[Hf]);function UN(t){var e=HN&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||zN&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Sa:$r)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}let Dn=typeof navigator<"u"?navigator:{userAgent:"",vendor:"",platform:""},zf=typeof document<"u"?document:{documentElement:{style:{}}};const Uf=/Edge\/(\d+)/.exec(Dn.userAgent),Qy=/MSIE \d/.test(Dn.userAgent),Vf=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn.userAgent),nc=!!(Qy||Vf||Uf),Wy=!nc&&/gecko\/(\d+)/i.test(Dn.userAgent),Ff=!nc&&/Chrome\/(\d+)/.exec(Dn.userAgent),Zy="webkitFontSmoothing"in zf.documentElement.style,Pf=!nc&&/Apple Computer/.test(Dn.vendor),eb=Pf&&(/Mobile\/\w+/.test(Dn.userAgent)||Dn.maxTouchPoints>2);var Oe={mac:eb||/Mac/.test(Dn.platform),windows:/Win/.test(Dn.platform),linux:/Linux|X11/.test(Dn.platform),ie:nc,ie_version:Qy?zf.documentMode||6:Vf?+Vf[1]:Uf?+Uf[1]:0,gecko:Wy,gecko_version:Wy?+(/Firefox\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,chrome:!!Ff,chrome_version:Ff?+Ff[1]:0,ios:eb,android:/Android\b/.test(Dn.userAgent),webkit:Zy,webkit_version:Zy?+(/\bAppleWebKit\/(\d+)/.exec(Dn.userAgent)||[0,0])[1]:0,safari:Pf,safari_version:Pf?+(/\bVersion\/(\d+(\.\d+)?)/.exec(Dn.userAgent)||[0,0])[1]:0,tabSize:zf.documentElement.style.tabSize!=null?"tab-size":"-moz-tab-size"};function Yf(t,e){for(let n in t)n=="class"&&e.class?e.class+=" "+t.class:n=="style"&&e.style?e.style+=";"+t.style:e[n]=t[n];return e}const ic=Object.create(null);function Kf(t,e,n){if(t==e)return!0;t||(t=ic),e||(e=ic);let r=Object.keys(t),s=Object.keys(e);if(r.length-0!=s.length-0)return!1;for(let a of r)if(a!=n&&(s.indexOf(a)==-1||t[a]!==e[a]))return!1;return!0}function VN(t,e){for(let n=t.attributes.length-1;n>=0;n--){let r=t.attributes[n].name;e[r]==null&&t.removeAttribute(r)}for(let n in e){let r=e[n];n=="style"?t.style.cssText=r:t.getAttribute(n)!=r&&t.setAttribute(n,r)}}function tb(t,e,n){let r=!1;if(e)for(let s in e)n&&s in n||(r=!0,s=="style"?t.style.cssText="":t.removeAttribute(s));if(n)for(let s in n)e&&e[s]==n[s]||(r=!0,s=="style"?t.style.cssText=n[s]:t.setAttribute(s,n[s]));return r}function FN(t){let e=Object.create(null);for(let n=0;n0?3e8:-4e8:n>0?1e8:-1e8,new js(e,n,n,r,e.widget||null,!1)}static replace(e){let n=!!e.block,r,s;if(e.isBlockGap)r=-5e8,s=4e8;else{let{start:a,end:c}=nb(e,n);r=(a?n?-3e8:-1:5e8)-1,s=(c?n?2e8:1:-6e8)+1}return new js(e,r,s,n,e.widget||null,!0)}static line(e){return new ka(e)}static set(e,n=!1){return pt.of(e,n)}hasHeight(){return this.widget?this.widget.estimatedHeight>-1:!1}}ln.none=pt.empty;class Aa extends ln{constructor(e){let{start:n,end:r}=nb(e);super(n?-1:5e8,r?1:-6e8,null,e),this.tagName=e.tagName||"span",this.attrs=e.class&&e.attributes?Yf(e.attributes,{class:e.class}):e.class?{class:e.class}:e.attributes||ic}eq(e){return this==e||e instanceof Aa&&this.tagName==e.tagName&&Kf(this.attrs,e.attrs)}range(e,n=e){if(e>=n)throw new RangeError("Mark decorations may not be empty");return super.range(e,n)}}Aa.prototype.point=!1;class ka extends ln{constructor(e){super(-2e8,-2e8,null,e)}eq(e){return e instanceof ka&&this.spec.class==e.spec.class&&Kf(this.spec.attributes,e.spec.attributes)}range(e,n=e){if(n!=e)throw new RangeError("Line decoration ranges must be zero-length");return super.range(e,n)}}ka.prototype.mapMode=Wn.TrackBefore,ka.prototype.point=!0;class js extends ln{constructor(e,n,r,s,a,c){super(n,r,a,e),this.block=s,this.isReplace=c,this.mapMode=s?n<=0?Wn.TrackBefore:Wn.TrackAfter:Wn.TrackDel}get type(){return this.startSide!=this.endSide?fn.WidgetRange:this.startSide<=0?fn.WidgetBefore:fn.WidgetAfter}get heightRelevant(){return this.block||!!this.widget&&(this.widget.estimatedHeight>=5||this.widget.lineBreaks>0)}eq(e){return e instanceof js&&PN(this.widget,e.widget)&&this.block==e.block&&this.startSide==e.startSide&&this.endSide==e.endSide}range(e,n=e){if(this.isReplace&&(e>n||e==n&&this.startSide>0&&this.endSide<=0))throw new RangeError("Invalid range for replacement decoration");if(!this.isReplace&&n!=e)throw new RangeError("Widget decorations can only have zero-length ranges");return super.range(e,n)}}js.prototype.point=!0;function nb(t,e=!1){let{inclusiveStart:n,inclusiveEnd:r}=t;return n==null&&(n=t.inclusive),r==null&&(r=t.inclusive),{start:n??e,end:r??e}}function PN(t,e){return t==e||!!(t&&e&&t.compare(e))}function ol(t,e,n,r=0){let s=n.length-1;s>=0&&n[s]+r>=t?n[s]=Math.max(n[s],e):n.push(t,e)}class Ca extends Ts{constructor(e,n,r){super(),this.tagName=e,this.attributes=n,this.rank=r}eq(e){return e==this||e instanceof Ca&&this.tagName==e.tagName&&Kf(this.attributes,e.attributes)}static create(e){return new Ca(e.tagName,e.attributes||ic,e.rank==null?50:Math.max(0,Math.min(e.rank,100)))}static set(e,n=!1){return pt.of(e,n)}}Ca.prototype.startSide=Ca.prototype.endSide=-1;function Na(t){let e;return t.nodeType==11?e=t.getSelection?t:t.ownerDocument:e=t,e.getSelection()}function Gf(t,e){return e?t==e||t.contains(e.nodeType!=1?e.parentNode:e):!1}function Ta(t,e){if(!e.anchorNode)return!1;try{return Gf(t,e.anchorNode)}catch{return!1}}function sc(t){return t.nodeType==3?Ea(t,0,t.nodeValue.length).getClientRects():t.nodeType==1?t.getClientRects():[]}function ja(t,e,n,r){return n?ib(t,e,n,r,-1)||ib(t,e,n,r,1):!1}function Ir(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e}function lc(t){return t.nodeType==1&&/^(DIV|P|LI|UL|OL|BLOCKQUOTE|DD|DT|H\d|SECTION|PRE)$/.test(t.nodeName)}function ib(t,e,n,r,s){for(;;){if(t==n&&e==r)return!0;if(e==(s<0?0:rr(t))){if(t.nodeName=="DIV")return!1;let a=t.parentNode;if(!a||a.nodeType!=1)return!1;e=Ir(t)+(s<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(s<0?-1:0)],t.nodeType==1&&t.contentEditable=="false")return!1;e=s<0?rr(t):0}else return!1}}function rr(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function ac(t,e){let{left:n,right:r}=t;if(n==r)return t;let s=e?n:r;return{left:s,right:s,top:t.top,bottom:t.bottom}}function YN(t){let e=t.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.innerWidth,top:0,bottom:t.innerHeight}}function rb(t,e){let n=e.width/t.offsetWidth,r=e.height/t.offsetHeight;return(n>.995&&n<1.005||!isFinite(n)||Math.abs(e.width-t.offsetWidth)<1)&&(n=1),(r>.995&&r<1.005||!isFinite(r)||Math.abs(e.height-t.offsetHeight)<1)&&(r=1),{scaleX:n,scaleY:r}}function KN(t,e,n,r,s,a,c,u){let f=t.ownerDocument,h=f.defaultView||window;for(let g=t,b=!1;g&&!b;)if(g.nodeType==1){let v,w=g==f.body,A=1,C=1;if(w)v=YN(h);else{if(/^(fixed|sticky)$/.test(getComputedStyle(g).position)&&(b=!0),g.scrollHeight<=g.clientHeight&&g.scrollWidth<=g.clientWidth){g=g.assignedSlot||g.parentNode;continue}let O=g.getBoundingClientRect();({scaleX:A,scaleY:C}=rb(g,O)),v={left:O.left,right:O.left+g.clientWidth*A,top:O.top,bottom:O.top+g.clientHeight*C}}let E=0,D=0;if(s=="nearest")e.top0&&e.bottom>v.bottom+D&&(D=e.bottom-v.bottom+c)):e.bottom>v.bottom-c&&(D=e.bottom-v.bottom+c,n<0&&e.top-D0&&e.right>v.right+E&&(E=e.right-v.right+a)):e.right>v.right-a&&(E=e.right-v.right+a,n<0&&e.leftv.bottom||e.leftv.right)&&(e={left:Math.max(e.left,v.left),right:Math.min(e.right,v.right),top:Math.max(e.top,v.top),bottom:Math.min(e.bottom,v.bottom)}),g=g.assignedSlot||g.parentNode}else if(g.nodeType==11)g=g.host;else break}function sb(t,e=!0){let n=t.ownerDocument,r=null,s=null;for(let a=t.parentNode;a&&!(a==n.body||(!e||r)&&s);)if(a.nodeType==1)!s&&a.scrollHeight>a.clientHeight&&(s=a),e&&!r&&a.scrollWidth>a.clientWidth&&(r=a),a=a.assignedSlot||a.parentNode;else if(a.nodeType==11)a=a.host;else break;return{x:r,y:s}}class GN{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){let{anchorNode:n,focusNode:r}=e;this.set(n,Math.min(e.anchorOffset,n?rr(n):0),r,Math.min(e.focusOffset,r?rr(r):0))}set(e,n,r,s){this.anchorNode=e,this.anchorOffset=n,this.focusNode=r,this.focusOffset=s}}function lb(t){let e=[];for(let n=t;n;n=n.nodeType==11?n.host:n.parentNode)n.nodeType==1&&e.push({node:n,left:n.scrollLeft,top:n.scrollTop});return e}function ab(t,e=!0){for(let{node:n,left:r,top:s}of t)e&&n.scrollTop!=s&&(n.scrollTop=s),n.scrollLeft!=r&&(n.scrollLeft=r)}let Es=null;Oe.safari&&Oe.safari_version>=26&&(Es=!1);function ob(t){if(t.setActive)return t.setActive();if(Es)return t.focus(Es);let e=lb(t);t.focus(Es==null?{get preventScroll(){return Es={preventScroll:!0},!0}}:void 0),Es||(Es=!1,ab(e))}let cb;function Ea(t,e,n=e){let r=cb||(cb=document.createRange());return r.setEnd(t,n),r.setStart(t,e),r}function cl(t,e,n,r){let s={key:e,code:e,keyCode:n,which:n,cancelable:!0};r&&({altKey:s.altKey,ctrlKey:s.ctrlKey,shiftKey:s.shiftKey,metaKey:s.metaKey}=r);let a=new KeyboardEvent("keydown",s);a.synthetic=!0,t.dispatchEvent(a);let c=new KeyboardEvent("keyup",s);return c.synthetic=!0,t.dispatchEvent(c),a.defaultPrevented||c.defaultPrevented}function XN(t){for(;t;){if(t&&(t.nodeType==9||t.nodeType==11&&t.host))return t;t=t.assignedSlot||t.parentNode}return null}function JN(t,e){let n=e.focusNode,r=e.focusOffset;if(!n||e.anchorNode!=n||e.anchorOffset!=r)return!1;for(r=Math.min(r,rr(n));;)if(r){if(n.nodeType!=1)return!1;let s=n.childNodes[r-1];s.contentEditable=="false"?r--:(n=s,r=rr(n))}else{if(n==t)return!0;r=Ir(n),n=n.parentNode}}function ub(t){return t instanceof Window?t.pageYOffset>Math.max(0,t.document.documentElement.scrollHeight-t.innerHeight-4):t.scrollTop>Math.max(1,t.scrollHeight-t.clientHeight-4)}function db(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r>0)return{node:n,offset:r};if(n.nodeType==1&&r>0){if(n.contentEditable=="false")return null;n=n.childNodes[r-1],r=rr(n)}else if(n.parentNode&&!lc(n))r=Ir(n),n=n.parentNode;else return null}}function fb(t,e){for(let n=t,r=e;;){if(n.nodeType==3&&r=n){if(u.level==r)return c;(a<0||(s!=0?s<0?u.fromn:e[a].level>u.level))&&(a=c)}}if(a<0)throw new RangeError("Index out of range");return a}}function mb(t,e){if(t.length!=e.length)return!1;for(let n=0;n=0;C-=3)if(Ui[C+1]==-w){let E=Ui[C+2],D=E&2?s:E&4?E&1?a:s:0;D&&(Ot[b]=Ot[Ui[C]]=D),u=C;break}}else{if(Ui.length==189)break;Ui[u++]=b,Ui[u++]=v,Ui[u++]=f}else if((A=Ot[b])==2||A==1){let C=A==s;f=C?0:1;for(let E=u-3;E>=0;E-=3){let D=Ui[E+2];if(D&2)break;if(C)Ui[E+2]|=2;else{if(D&4)break;Ui[E+2]|=4}}}}}function nT(t,e,n,r){for(let s=0,a=r;s<=n.length;s++){let c=s?n[s-1].to:t,u=sf;)A==E&&(A=n[--C].from,E=C?n[C-1].to:t),Ot[--A]=w;f=g}else a=h,f++}}}function Qf(t,e,n,r,s,a,c){let u=r%2?2:1;if(r%2==s%2)for(let f=e,h=0;ff&&c.push(new Vi(f,C.from,w));let E=C.direction==Os!=!(w%2);Wf(t,E?r+1:r,s,C.inner,C.from,C.to,c),f=C.to}A=C.to}else{if(A==n||(g?Ot[A]!=u:Ot[A]==u))break;A++}v?Qf(t,f,A,r+1,s,v,c):fe;){let g=!0,b=!1;if(!h||f>a[h-1].to){let C=Ot[f-1];C!=u&&(g=!1,b=C==16)}let v=!g&&u==1?[]:null,w=g?r:r+1,A=f;e:for(;;)if(h&&A==a[h-1].to){if(b)break e;let C=a[--h];if(!g)for(let E=C.from,D=h;;){if(E==e)break e;if(D&&a[D-1].to==E)E=a[--D].from;else{if(Ot[E-1]==u)break e;break}}if(v)v.push(C);else{C.toOt.length;)Ot[Ot.length]=256;let r=[],s=e==Os?0:1;return Wf(t,s,s,n,0,t.length,r),r}function gb(t){return[new Vi(0,t,0)]}let yb="";function rT(t,e,n,r,s){var a;let c=r.head-t.from,u=Vi.find(e,c,(a=r.bidiLevel)!==null&&a!==void 0?a:-1,r.assoc),f=e[u],h=f.side(s,n);if(c==h){let v=u+=s?1:-1;if(v<0||v>=e.length)return null;f=e[u=v],c=f.side(!s,n),h=f.side(s,n)}let g=kn(t.text,c,f.forward(s,n));(gf.to)&&(g=h),yb=t.text.slice(Math.min(c,g),Math.max(c,g));let b=u==(s?e.length-1:0)?null:e[u+(s?1:-1)];return b&&g==h&&b.level+(s?0:1)t.some(e=>e)}),Cb=Ue.define({combine:t=>t.some(e=>e)}),Nb=Ue.define();class ul{constructor(e,n,r,s,a,c=!1){this.range=e,this.y=n,this.x=r,this.yMargin=s,this.xMargin=a,this.isSnapshot=c}map(e){return e.empty?this:new ul(this.range.map(e),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}clip(e){return this.range.to<=e.doc.length?this:new ul(ke.cursor(e.doc.length),this.y,this.x,this.yMargin,this.xMargin,this.isSnapshot)}}const oc=Ft.define({map:(t,e)=>t.map(e)}),Tb=Ft.define();function Fi(t,e,n){let r=t.facet(wb);r.length?r[0](e):window.onerror&&window.onerror(String(e),n,void 0,void 0,e)||(n?console.error(n+":",e):console.error(e))}const sr=Ue.define({combine:t=>t.length?t[0]:!0});let lT=0;const dl=Ue.define({combine(t){return t.filter((e,n)=>{for(let r=0;r{let f=[];return c&&f.push(cc.of(h=>{let g=h.plugin(u);return g?c(g):ln.none})),a&&f.push(a(u)),f})}static fromClass(e,n){return lr.define((r,s)=>new e(r,s),n)}}class nh{constructor(e){this.spec=e,this.mustUpdate=null,this.value=null}get plugin(){return this.spec&&this.spec.plugin}update(e){if(this.value){if(this.mustUpdate){let n=this.mustUpdate;if(this.mustUpdate=null,this.value.update)try{this.value.update(n)}catch(r){if(Fi(n.state,r,"CodeMirror plugin crashed"),this.value.destroy)try{this.value.destroy()}catch{}this.deactivate()}}}else if(this.spec)try{this.value=this.spec.plugin.create(e,this.spec.arg)}catch(n){Fi(e.state,n,"CodeMirror plugin crashed"),this.deactivate()}return this}destroy(e){var n;if(!((n=this.value)===null||n===void 0)&&n.destroy)try{this.value.destroy()}catch(r){Fi(e.state,r,"CodeMirror plugin crashed")}}deactivate(){this.spec=this.value=null}}const jb=Ue.define(),ih=Ue.define(),cc=Ue.define(),Eb=Ue.define(),rh=Ue.define(),Oa=Ue.define(),Ob=Ue.define();function Mb(t,e){let n=t.state.facet(Ob);if(!n.length)return n;let r=n.map(a=>a instanceof Function?a(t):a),s=[];return pt.spans(r,e.from,e.to,{point(){},span(a,c,u,f){let h=a-e.from,g=c-e.from,b=s;for(let v=u.length-1;v>=0;v--,f--){let w=u[v].spec.bidiIsolate,A;if(w==null&&(w=sT(e.text,h,g)),f>0&&b.length&&(A=b[b.length-1]).to==h&&A.direction==w)A.to=g,b=A.inner;else{let C={from:h,to:g,direction:w,inner:[]};b.push(C),b=C.inner}}}}),s}const Rb=Ue.define();function Db(t){let e=0,n=0,r=0,s=0;for(let a of t.state.facet(Rb)){let c=a(t);c&&(c.left!=null&&(e=Math.max(e,c.left)),c.right!=null&&(n=Math.max(n,c.right)),c.top!=null&&(r=Math.max(r,c.top)),c.bottom!=null&&(s=Math.max(s,c.bottom)))}return{left:e,right:n,top:r,bottom:s}}const Ma=Ue.define();class pi{constructor(e,n,r,s){this.fromA=e,this.toA=n,this.fromB=r,this.toB=s}join(e){return new pi(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 n=e.length,r=this;for(;n>0;n--){let s=e[n-1];if(!(s.fromA>r.toA)){if(s.toAs.push(new pi(a,c,u,f))),this.changedRanges=s}static create(e,n,r){return new uc(e,n,r)}get viewportChanged(){return(this.flags&4)>0}get viewportMoved(){return(this.flags&8)>0}get heightChanged(){return(this.flags&2)>0}get geometryChanged(){return this.docChanged||(this.flags&18)>0}get focusChanged(){return(this.flags&1)>0}get docChanged(){return!this.changes.empty}get selectionSet(){return this.transactions.some(e=>e.selection)}get empty(){return this.flags==0&&this.transactions.length==0}}const aT=[];class Ht{constructor(e,n,r=0){this.dom=e,this.length=n,this.flags=r,this.parent=null,e.cmTile=this}get breakAfter(){return this.flags&1}get children(){return aT}isWidget(){return!1}get isHidden(){return!1}isComposite(){return!1}isLine(){return!1}isText(){return!1}isBlock(){return!1}get domAttrs(){return null}sync(e){if(this.flags|=2,this.flags&4){this.flags&=-5;let n=this.domAttrs;n&&VN(this.dom,n)}}toString(){return this.constructor.name+(this.children.length?`(${this.children})`:"")+(this.breakAfter?"#":"")}destroy(){this.parent=null}setDOM(e){this.dom=e,e.cmTile=this}get posAtStart(){return this.parent?this.parent.posBefore(this):0}get posAtEnd(){return this.posAtStart+this.length}posBefore(e,n=this.posAtStart){let r=n;for(let s of this.children){if(s==e)return r;r+=s.length+s.breakAfter}throw new RangeError("Invalid child in posBefore")}posAfter(e){return this.posBefore(e)+e.length}covers(e){return!0}coordsIn(e,n,r){return null}domPosFor(e,n){let r=Ir(this.dom),s=this.length?e>0:n>0;return new Oi(this.parent.dom,r+(s?1:0),e==0||e==this.length)}markDirty(e){this.flags&=-3,e&&(this.flags|=4),this.parent&&this.parent.flags&2&&this.parent.markDirty(!1)}get overrideDOMText(){return null}get root(){for(let e=this;e;e=e.parent)if(e instanceof fc)return e;return null}static get(e){return e.cmTile}}class dc extends Ht{constructor(e){super(e,0),this._children=[]}isComposite(){return!0}get children(){return this._children}get lastChild(){return this.children.length?this.children[this.children.length-1]:null}append(e){this.children.push(e),e.parent=this}sync(e){if(this.flags&2)return;super.sync(e);let n=this.dom,r=null,s,a=e?.node==n?e:null,c=0;for(let u of this.children){if(u.sync(e),c+=u.length+u.breakAfter,s=r?r.nextSibling:n.firstChild,a&&s!=u.dom&&(a.written=!0),u.dom.parentNode==n)for(;s&&s!=u.dom;)s=_b(s);else n.insertBefore(u.dom,s);r=u.dom}for(s=r?r.nextSibling:n.firstChild,a&&s&&(a.written=!0);s;)s=_b(s);this.length=c}}function _b(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fc extends dc{constructor(e,n){super(n),this.view=e}owns(e){for(;e;e=e.parent)if(e==this)return!0;return!1}isBlock(){return!0}nearest(e){for(;;){if(!e)return null;let n=Ht.get(e);if(n&&this.owns(n))return n;e=e.parentNode}}blockTiles(e){for(let n=[],r=this,s=0,a=0;;)if(s==r.children.length){if(!n.length)return;r=r.parent,r.breakAfter&&a++,s=n.pop()}else{let c=r.children[s++];if(c instanceof ar)n.push(s),r=c,s=0;else{let u=a+c.length,f=e(c,a);if(f!==void 0)return f;a=u+c.breakAfter}}}resolveBlock(e,n){let r,s=-1,a,c=-1;if(this.blockTiles((u,f)=>{let h=f+u.length;if(e>=f&&e<=h){if(u.isWidget()&&n>=-1&&n<=1){if(u.flags&32)return!0;u.flags&16&&(r=void 0)}(fe||e==f&&(n>1?u.length:u.covers(-1)))&&(!a||!u.isWidget()&&a.isWidget())&&(a=u,c=e-f)}}),!r&&!a)throw new Error("No tile at position "+e);return r&&n<0||!a?{tile:r,offset:s}:{tile:a,offset:c}}}class ar extends dc{constructor(e,n){super(e),this.wrapper=n}isBlock(){return!0}covers(e){return this.children.length?e<0?this.children[0].covers(-1):this.lastChild.covers(1):!1}get domAttrs(){return this.wrapper.attributes}static of(e,n){let r=new ar(n||document.createElement(e.tagName),e);return n||(r.flags|=4),r}}class fl extends dc{constructor(e,n){super(e),this.attrs=n}isLine(){return!0}static start(e,n,r){let s=new fl(n||document.createElement("div"),e);return(!n||!r)&&(s.flags|=4),s}get domAttrs(){return this.attrs}resolveInline(e,n,r){let s=null,a=-1,c=null,u=-1;function f(g,b){for(let v=0,w=0;v=b&&(A.isComposite()?f(A,b-w):(!c||c.isHidden&&(n>0&&!(c.flags&32)||r&&cT(c,A)))&&(C>b||A.flags&32&&n<=1)?(c=A,u=b-w):(w=-1)&&(s=A,a=b-w)),w=C}}f(this,e);let h=(n<0?s:c)||s||c;return h?{tile:h,offset:h==s?a:u}:null}coordsIn(e,n,r){let s=this.resolveInline(e,n,!0);return s?s.tile.coordsIn(Math.max(0,s.offset),n,r):oT(this)}domIn(e,n){let r=this.resolveInline(e,n);if(r){let{tile:s,offset:a}=r;if(this.dom.contains(s.dom))return s.isText()?new Oi(s.dom,Math.min(s.dom.nodeValue.length,a)):s.domPosFor(a,s.flags&16?1:s.flags&32?-1:n);let c=r.tile.parent,u=!1;for(let f of c.children){if(u)return new Oi(f.dom,0);f==r.tile&&(u=!0)}}return new Oi(this.dom,0)}}function oT(t){let e=t.dom.lastChild;if(!e)return t.dom.getBoundingClientRect();let n=sc(e);return n[n.length-1]||null}function cT(t,e){let n=t.coordsIn(0,1),r=e.coordsIn(0,1);return n&&r&&r.tops&&(e=s);let a=e,c=e,u=0;e==0&&n<0||e==s&&n>=0?Oe.chrome||Oe.gecko||(e?(a--,u=1):c=0)?0:f.length-1];return Oe.safari&&!u&&h.width==0&&(h=Array.prototype.find.call(f,g=>g.width)||h),r==null?h:ac(h,(u?u>0:n<0)==r)}static of(e,n){let r=new Ms(n||document.createTextNode(e),e);return n||(r.flags|=2),r}}class Rs extends Ht{constructor(e,n,r,s){super(e,n,s),this.widget=r}isWidget(){return!0}get isHidden(){return this.widget.isHidden}covers(e){return this.flags&48?!1:(this.flags&(e<0?64:128))>0}coordsIn(e,n){return this.coordsInWidget(e,n,!1)}coordsInWidget(e,n,r){let s=this.widget.coordsAt(this.dom,e,n);if(s)return s;if(r)return ac(this.dom.getBoundingClientRect(),this.length?e==0:n<=0);{let a=this.dom.getClientRects(),c=null;if(!a.length)return null;let u=this.flags&16?!0:this.flags&32?!1:e>0;for(let f=u?a.length-1:0;c=a[f],!(e>0?f==0:f==a.length-1||c.top0==r)}}class uT{constructor(e){this.index=0,this.beforeBreak=!1,this.parents=[],this.tile=e}advance(e,n,r){let{tile:s,index:a,beforeBreak:c,parents:u}=this;for(;e||n>0;)if(s.isComposite())if(c){if(!e)break;r&&r.break(),e--,c=!1}else if(a==s.children.length){if(!e&&!u.length)break;r&&r.leave(s),c=!!s.breakAfter,{tile:s,index:a}=u.pop(),a++}else{let f=s.children[a],h=f.breakAfter;(n>0?f.length<=e:f.length=0;u--){let f=n.marks[u],h=s.lastChild;if(h instanceof Hn&&h.mark.eq(f.mark))h.dom!=f.dom&&h.setDOM(sh(f.dom)),s=h;else{if(this.cache.reused.get(f)){let b=Ht.get(f.dom);b&&b.setDOM(sh(f.dom))}let g=Hn.of(f.mark,f.dom);s.append(g),s=g}this.cache.reused.set(f,2)}let a=Ht.get(e.text);a&&this.cache.reused.set(a,2);let c=new Ms(e.text,e.text.nodeValue);c.flags|=8,this.pos=e.range.toB,s.append(c)}addInlineWidget(e,n,r){let s=this.afterWidget&&e.flags&48&&(this.afterWidget.flags&48)==(e.flags&48);s||this.flushBuffer();let a=this.ensureMarks(n,r);!s&&!(e.flags&16)&&a.append(this.getBuffer(1)),a.append(e),this.pos+=e.length,this.afterWidget=e}addMark(e,n,r){this.flushBuffer(),this.ensureMarks(n,r).append(e),this.pos+=e.length,this.afterWidget=null}addBlockWidget(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}continueWidget(e){let n=this.afterWidget||this.lastBlock;n.length+=e,this.pos+=e}addLineStart(e,n){var r;e||(e=qb);let s=fl.start(e,n||((r=this.cache.find(fl))===null||r===void 0?void 0:r.dom),!!n);this.getBlockPos().append(this.lastBlock=this.curLine=s)}addLine(e){this.getBlockPos().append(e),this.pos+=e.length,this.lastBlock=e,this.endLine()}addBreak(){this.lastBlock.flags|=1,this.endLine(),this.pos++}addLineStartIfNotCovered(e){this.blockPosCovered()||this.addLineStart(e)}ensureLine(e){this.curLine||this.addLineStart(e)}ensureMarks(e,n){var r;let s=this.curLine;for(let a=e.length-1;a>=0;a--){let c=e[a],u;if(n>0&&(u=s.lastChild)&&u instanceof Hn&&u.mark.eq(c))s=u,n--;else{let f=Hn.of(c,(r=this.cache.find(Hn,h=>h.mark.eq(c)))===null||r===void 0?void 0:r.dom);s.append(f),s=f,n=0}}return s}endLine(){if(this.curLine){this.flushBuffer();let e=this.curLine.lastChild;(!e||!Lb(this.curLine,!1)||e.dom.nodeName!="BR"&&e.isWidget()&&!(Oe.ios&&Lb(this.curLine,!0)))&&this.curLine.append(this.cache.findWidget(lh,0,32)||new Rs(lh.toDOM(),0,lh,32)),this.curLine=this.afterWidget=null}}updateBlockWrappers(){this.wrapperPos>this.pos+1e4&&(this.blockWrappers.goto(this.pos),this.wrappers.length=0);for(let e=this.wrappers.length-1;e>=0;e--)this.wrappers[e].to=this.pos){let n=e.rank*102+e.value.rank,r=new dT(e.from,e.to,e.value,n),s=this.wrappers.length;for(;s>0&&(this.wrappers[s-1].rank-r.rank||this.wrappers[s-1].to-r.to)<0;)s--;this.wrappers.splice(s,0,r)}this.wrapperPos=this.pos}getBlockPos(){var e;this.updateBlockWrappers();let n=this.root;for(let r of this.wrappers){let s=n.lastChild;if(r.fromc.wrapper.eq(r.wrapper)))===null||e===void 0?void 0:e.dom);n.append(a),n=a}}return n}blockPosCovered(){let e=this.lastBlock;return e!=null&&!e.breakAfter&&(!e.isWidget()||(e.flags&160)>0)}getBuffer(e){let n=2|(e<0?16:32),r=this.cache.find(hc,void 0,1);return r&&(r.flags=n),r||new hc(n)}flushBuffer(){this.afterWidget&&!(this.afterWidget.flags&32)&&(this.afterWidget.parent.append(this.getBuffer(-1)),this.afterWidget=null)}}class hT{constructor(e){this.skipCount=0,this.text="",this.textOff=0,this.cursor=e.iter()}skip(e){this.textOff+e<=this.text.length?this.textOff+=e:(this.skipCount+=e-(this.text.length-this.textOff),this.text="",this.textOff=0)}next(e){if(this.textOff==this.text.length){let{value:s,lineBreak:a,done:c}=this.cursor.next(this.skipCount);if(this.skipCount=0,c)throw new Error("Ran out of text content when drawing inline views");this.text=s;let u=this.textOff=Math.min(e,s.length);return a?null:s.slice(0,u)}let n=Math.min(this.text.length,this.textOff+e),r=this.text.slice(this.textOff,n);return this.textOff=n,r}}const pc=[Rs,fl,Ms,Hn,hc,ar,fc];for(let t=0;t[]),this.index=pc.map(()=>0),this.reused=new Map}add(e){let n=e.constructor.bucket,r=this.buckets[n];r.length<6?r.push(e):r[this.index[n]=(this.index[n]+1)%6]=e}find(e,n,r=2){let s=e.bucket,a=this.buckets[s],c=this.index[s];for(let u=0;u{if(this.cache.add(c),c.isComposite())return!1},enter:c=>this.cache.add(c),leave:()=>{},break:()=>{}}}run(e,n){let r=n&&this.getCompositionContext(n.text);for(let s=0,a=0,c=0;;){let u=cs){let h=f-s;this.preserve(h,!c,!u),s=f,a+=h}if(!u)break;n&&u.fromA<=n.range.fromA&&u.toA>=n.range.toA?(this.forward(u.fromA,n.range.fromA,n.range.fromA{if(c.isWidget())if(this.openWidget)this.builder.continueWidget(f-u);else{let h=f>0||u{c.isLine()?this.builder.addLineStart(c.attrs,this.cache.maybeReuse(c)):(this.cache.add(c),c instanceof Hn&&s.unshift(c.mark)),this.openWidget=!1},leave:c=>{c.isLine()?s.length&&(s.length=a=0):c instanceof Hn&&(s.shift(),a=Math.min(a,s.length))},break:()=>{this.builder.addBreak(),this.openWidget=!1}}),this.text.skip(e)}emit(e,n){let r=null,s=this.builder,a=-1,c=pt.spans(this.decorations,e,n,{point:(u,f,h,g,b,v)=>{if(h instanceof js){if(this.disallowBlockEffectsFor[v]){if(h.block)throw new RangeError("Block decorations may not be specified via plugins");if(f>this.view.state.doc.lineAt(u).to)throw new RangeError("Decorations that replace line breaks may not be specified via plugins")}if(a=g.length,b>g.length)s.continueWidget(f-u);else{let w=h.widget||(h.block?hl.block:hl.inline),A=gT(h),C=this.cache.findWidget(w,f-u,A)||Rs.of(w,this.view,f-u,A);h.block?(h.startSide>0&&s.addLineStartIfNotCovered(r),s.addBlockWidget(C)):(s.ensureLine(r),s.addInlineWidget(C,g,b))}r=null}else r=yT(r,h);f>u&&this.text.skip(f-u)},span:(u,f,h,g)=>{for(let b=u;b-1&&(this.openWidget=c>a),this.openWidget||s.addLineStartIfNotCovered(r),this.openMarks=c}forward(e,n,r=1){n-e<=10?this.old.advance(n-e,r,this.reuseWalker):(this.old.advance(5,-1,this.reuseWalker),this.old.advance(n-e-10,-1),this.old.advance(5,r,this.reuseWalker))}getCompositionContext(e){let n=[],r=null;for(let s=e.parentNode;;s=s.parentNode){let a=Ht.get(s);if(s==this.view.contentDOM)break;a instanceof Hn?n.push(a):a?.isLine()?r=a:a instanceof ar||(s.nodeName=="DIV"&&!r&&s!=this.view.contentDOM?r=new fl(s,qb):r||n.push(Hn.of(new Aa({tagName:s.nodeName.toLowerCase(),attributes:FN(s)}),s)))}return{line:r,marks:n}}}function Lb(t,e){let n=r=>{for(let s of r.children)if((e?s.isText():s.length)||n(s))return!0;return!1};return n(t)}function gT(t){let e=t.isReplace?(t.startSide<0?64:0)|(t.endSide>0?128:0):t.startSide>0?32:16;return t.block&&(e|=256),e}const qb={class:"cm-line"};function yT(t,e){let n=e.spec.attributes,r=e.spec.class;return!n&&!r||(t||(t={class:"cm-line"}),n&&Yf(n,t),r&&(t.class+=" "+r)),t}function bT(t){let e=[];for(let n=t.parents.length;n>1;n--){let r=n==t.parents.length?t.tile:t.parents[n].tile;r instanceof Hn&&e.push(r.mark)}return e}function sh(t){let e=Ht.get(t);return e&&e.setDOM(t.cloneNode()),t}class hl extends rc{constructor(e){super(),this.tag=e}eq(e){return e.tag==this.tag}toDOM(){return document.createElement(this.tag)}updateDOM(e){return e.nodeName.toLowerCase()==this.tag}get isHidden(){return!0}}hl.inline=new hl("span"),hl.block=new hl("div");const lh=new class extends rc{toDOM(){return document.createElement("br")}get isHidden(){return!0}get editable(){return!0}};class Bb{constructor(e){this.view=e,this.decorations=[],this.blockWrappers=[],this.dynamicDecorationMap=[!1],this.domChanged=null,this.hasComposition=null,this.editContextFormatting=ln.none,this.lastCompositionAfterCursor=!1,this.minWidth=0,this.minWidthFrom=0,this.minWidthTo=0,this.impreciseAnchor=null,this.impreciseHead=null,this.forceSelection=!1,this.lastUpdate=Date.now(),this.updateDeco(),this.tile=new fc(e,e.contentDOM),this.updateInner([new pi(0,0,0,e.state.doc.length)],null)}update(e){var n;let r=e.changedRanges;this.minWidth>0&&r.length&&(r.every(({fromA:g,toA:b})=>bthis.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.updateEditContextFormatting(e);let s=-1;this.view.inputState.composing>=0&&!this.view.observer.editContext&&(!((n=this.domChanged)===null||n===void 0)&&n.newSel?s=this.domChanged.newSel.head:!TT(e.changes,this.hasComposition)&&!e.selectionSet&&(s=e.state.selection.main.head));let a=s>-1?vT(this.view,e.changes,s):null;if(this.domChanged=null,this.hasComposition){let{from:g,to:b}=this.hasComposition;r=new pi(g,b,e.changes.mapPos(g,-1),e.changes.mapPos(b,1)).addToSet(r.slice())}this.hasComposition=a?{from:a.range.fromB,to:a.range.toB}:null,(Oe.ie||Oe.chrome)&&!a&&e&&e.state.doc.lines!=e.startState.doc.lines&&(this.forceSelection=!0);let c=this.decorations,u=this.blockWrappers;this.updateDeco();let f=AT(c,this.decorations,e.changes);f.length&&(r=pi.extendWithRanges(r,f));let h=CT(u,this.blockWrappers,e.changes);return h.length&&(r=pi.extendWithRanges(r,h)),a&&!r.some(g=>g.fromA<=a.range.fromA&&g.toA>=a.range.toA)&&(r=a.range.addToSet(r.slice())),this.tile.flags&2&&r.length==0?!1:(this.updateInner(r,a),e.transactions.length&&(this.lastUpdate=Date.now()),!0)}updateInner(e,n){this.view.viewState.mustMeasureContent=!0;let{observer:r}=this.view;r.ignore(()=>{if(n||e.length){let c=this.tile,u=new mT(this.view,c,this.blockWrappers,this.decorations,this.dynamicDecorationMap);n&&Ht.get(n.text)&&u.cache.reused.set(Ht.get(n.text),2),this.tile=u.run(e,n),ah(c,u.cache.reused)}this.tile.dom.style.height=this.view.viewState.contentHeight/this.view.scaleY+"px",this.tile.dom.style.flexBasis=this.minWidth?this.minWidth+"px":"";let a=Oe.chrome||Oe.ios?{node:r.selectionRange.focusNode,written:!1}:void 0;this.tile.sync(a),a&&(a.written||r.selectionRange.focusNode!=a.node||!this.tile.dom.contains(a.node))&&(this.forceSelection=!0),this.tile.dom.style.height=""});let s=[];if(this.view.viewport.from||this.view.viewport.to-1)&&Ta(r,this.view.observer.selectionRange)&&!(s&&r.contains(s));if(!(a||n||c))return;let u=this.forceSelection;this.forceSelection=!1;let f=this.view.state.selection.main,h,g;if(f.empty?g=h=this.inlineDOMNearPos(f.anchor,f.assoc||1):(g=this.inlineDOMNearPos(f.head,f.head==f.from?1:-1),h=this.inlineDOMNearPos(f.anchor,f.anchor==f.from?1:-1)),Oe.gecko&&f.empty&&!this.hasComposition&&xT(h)){let v=document.createTextNode("");this.view.observer.ignore(()=>h.node.insertBefore(v,h.node.childNodes[h.offset]||null)),h=g=new Oi(v,0),u=!0}let b=this.view.observer.selectionRange;(u||!b.focusNode||(!ja(h.node,h.offset,b.anchorNode,b.anchorOffset)||!ja(g.node,g.offset,b.focusNode,b.focusOffset))&&!this.suppressWidgetCursorChange(b,f))&&(this.view.observer.ignore(()=>{Oe.android&&Oe.chrome&&r.contains(b.focusNode)&&NT(b.focusNode,r)&&(r.blur(),r.focus({preventScroll:!0}));let v=Na(this.view.root);if(v)if(f.empty){if(Oe.gecko){let w=wT(h.node,h.offset);if(w&&w!=3){let A=(w==1?db:fb)(h.node,h.offset);A&&(h=new Oi(A.node,A.offset))}}v.collapse(h.node,h.offset),f.bidiLevel!=null&&v.caretBidiLevel!==void 0&&(v.caretBidiLevel=f.bidiLevel)}else if(v.extend){v.collapse(h.node,h.offset);try{v.extend(g.node,g.offset)}catch{}}else{let w=document.createRange();f.anchor>f.head&&([h,g]=[g,h]),w.setEnd(g.node,g.offset),w.setStart(h.node,h.offset),v.removeAllRanges(),v.addRange(w)}c&&this.view.root.activeElement==r&&(r.blur(),s&&s.focus())}),this.view.observer.setSelectionRange(h,g)),this.impreciseAnchor=h.precise?null:new Oi(b.anchorNode,b.anchorOffset),this.impreciseHead=g.precise?null:new Oi(b.focusNode,b.focusOffset)}suppressWidgetCursorChange(e,n){return this.hasComposition&&n.empty&&ja(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)&&this.posFromDOM(e.focusNode,e.focusOffset)==n.head}enforceCursorAssoc(){if(this.hasComposition)return;let{view:e}=this,n=e.state.selection.main,r=Na(e.root),{anchorNode:s,anchorOffset:a}=e.observer.selectionRange;if(!r||!n.empty||!n.assoc||!r.modify)return;let c=this.lineAt(n.head,n.assoc);if(!c)return;let u=c.posAtStart;if(n.head==u||n.head==u+c.length)return;let f=this.coordsAt(n.head,-1),h=this.coordsAt(n.head,1);if(!f||!h||f.bottom>h.top)return;let g=this.domAtPos(n.head+n.assoc,n.assoc);r.collapse(g.node,g.offset),r.modify("move",n.assoc<0?"forward":"backward","lineboundary"),e.observer.readSelectionRange();let b=e.observer.selectionRange;e.docView.posFromDOM(b.anchorNode,b.anchorOffset)!=n.from&&r.collapse(s,a)}posFromDOM(e,n){let r=this.tile.nearest(e);if(!r)return this.tile.dom.compareDocumentPosition(e)&2?0:this.view.state.doc.length;let s=r.posAtStart;if(r.isComposite()){let a;if(e==r.dom)a=r.dom.childNodes[n];else{let c=rr(e)==0?0:n==0?-1:1;for(;;){let u=e.parentNode;if(u==r.dom)break;c==0&&u.firstChild!=u.lastChild&&(e==u.firstChild?c=-1:c=1),e=u}c<0?a=e:a=e.nextSibling}if(a==r.dom.firstChild)return s;for(;a&&!Ht.get(a);)a=a.nextSibling;if(!a)return s+r.length;for(let c=0,u=s;;c++){let f=r.children[c];if(f.dom==a)return u;u+=f.length+f.breakAfter}}else return r.isText()?e==r.dom?s+n:s+(n?r.length:0):s}domAtPos(e,n){let{tile:r,offset:s}=this.tile.resolveBlock(e,n);return r.isWidget()?r.domPosFor(s,n):r.domIn(s,n)}inlineDOMNearPos(e,n){let r,s=-1,a=!1,c,u=-1,f=!1;return this.tile.blockTiles((h,g)=>{if(h.isWidget()){if(h.flags&32&&g>=e)return!0;h.flags&16&&(a=!0)}else{let b=g+h.length;if(g<=e&&(r=h,s=e-g,a=b=e&&!c&&(c=h,u=e-g,f=g>e),g>e&&c)return!0}}),!r&&!c?this.domAtPos(e,n):(a&&c?r=null:f&&r&&(c=null),r&&n<0||!c?r.domIn(s,n):c.domIn(u,n))}coordsAt(e,n,r){let{tile:s,offset:a}=this.tile.resolveBlock(e,n);return s.isWidget()?s.widget instanceof oh?null:s.coordsInWidget(a,n,!0):s.coordsIn(a,n,r)}lineAt(e,n){let{tile:r}=this.tile.resolveBlock(e,n);return r.isLine()?r:null}coordsForChar(e){let{tile:n,offset:r}=this.tile.resolveBlock(e,1);if(!n.isLine())return null;function s(a,c){if(a.isComposite())for(let u of a.children){if(u.length>=c){let f=s(u,c);if(f)return f}if(c-=u.length,c<0)break}else if(a.isText()&&cMath.max(this.view.scrollDOM.clientWidth,this.minWidth)+1,u=-1,f=this.view.textDirection==Bt.LTR,h=0,g=(b,v,w)=>{for(let A=0;As);A++){let C=b.children[A],E=v+C.length,D=C.dom.getBoundingClientRect(),{height:O}=D;if(w&&!A&&(h+=D.top-w.top),C instanceof ar)E>r&&g(C,v,D);else if(v>=r&&(h>0&&n.push(-h),n.push(O+h),h=0,c)){let j=C.dom.lastChild,R=j?sc(j):[];if(R.length){let _=R[R.length-1],L=f?_.right-D.left:D.right-_.left;L>u&&(u=L,this.minWidth=a,this.minWidthFrom=v,this.minWidthTo=E)}}w&&A==b.children.length-1&&(h+=w.bottom-D.bottom),v=E+C.breakAfter}};return g(this.tile,0,null),n}textDirectionAt(e){let{tile:n}=this.tile.resolveBlock(e,1);return getComputedStyle(n.dom).direction=="rtl"?Bt.RTL:Bt.LTR}measureTextSize(){let e=this.tile.blockTiles(c=>{if(c.isLine()&&c.children.length&&c.length<=20){let u=0,f;for(let h of c.children){if(!h.isText()||/[^ -~]/.test(h.text))return;let g=sc(h.dom);if(g.length!=1)return;u+=g[0].width,f=g[0].height}if(u)return{lineHeight:c.dom.getBoundingClientRect().height,charWidth:u/c.length,textHeight:f}}});if(e)return e;let n=document.createElement("div"),r,s,a;return n.className="cm-line",n.style.width="99999px",n.style.position="absolute",n.textContent="abc def ghi jkl mno pqr stu",this.view.observer.ignore(()=>{this.tile.dom.appendChild(n);let c=sc(n.firstChild)[0];r=n.getBoundingClientRect().height,s=c&&c.width?c.width/27:7,a=c&&c.height?c.height:r,n.remove()}),{lineHeight:r,charWidth:s,textHeight:a}}computeBlockGapDeco(){let e=[],n=this.view.viewState;for(let r=0,s=0;;s++){let a=s==n.viewports.length?null:n.viewports[s],c=a?a.from-1:this.view.state.doc.length;if(c>r){let u=(n.lineBlockAt(c).bottom-n.lineBlockAt(r).top)/this.view.scaleY;e.push(ln.replace({widget:new oh(u),block:!0,inclusive:!0,isBlockGap:!0}).range(r,c))}if(!a)break;r=a.to+1}return ln.set(e)}updateDeco(){let e=1,n=this.view.state.facet(cc).map(a=>(this.dynamicDecorationMap[e++]=typeof a=="function")?a(this.view):a),r=!1,s=this.view.state.facet(rh).map((a,c)=>{let u=typeof a=="function";return u&&(r=!0),u?a(this.view):a});for(s.length&&(this.dynamicDecorationMap[e++]=r,n.push(pt.join(s))),this.decorations=[this.editContextFormatting,...n,this.computeBlockGapDeco(),this.view.viewState.lineGapDeco];etypeof a=="function"?a(this.view):a)}scrollIntoView(e){if(e.isSnapshot){let h=this.view.viewState.lineBlockAt(e.range.head);this.view.scrollDOM.scrollTop=h.top-e.yMargin,this.view.scrollDOM.scrollLeft=e.xMargin;return}for(let h of this.view.state.facet(Nb))try{if(h(this.view,e.range,e))return!0}catch(g){Fi(this.view.state,g,"scroll handler")}let{range:n}=e,r=this.coordsAt(n.head,n.assoc||(n.head>n.anchor?-1:1)),s;if(!r)return;!n.empty&&(s=this.coordsAt(n.anchor,n.anchor>n.head?-1:1))&&(r={left:Math.min(r.left,s.left),top:Math.min(r.top,s.top),right:Math.max(r.right,s.right),bottom:Math.max(r.bottom,s.bottom)});let a=Db(this.view),c={left:r.left-a.left,top:r.top-a.top,right:r.right+a.right,bottom:r.bottom+a.bottom},{offsetWidth:u,offsetHeight:f}=this.view.scrollDOM;if(KN(this.view.scrollDOM,c,n.head1&&(r.top>window.visualViewport.offsetTop+window.visualViewport.height||r.bottomr.isWidget()||r.children.some(n);return n(this.tile.resolveBlock(e,1).tile)}destroy(){ah(this.tile)}}function ah(t,e){let n=e?.get(t);if(n!=1){n==null&&t.destroy();for(let r of t.children)ah(r,e)}}function xT(t){return t.node.nodeType==1&&t.node.firstChild&&(t.offset==0||t.node.childNodes[t.offset-1].contentEditable=="false")&&(t.offset==t.node.childNodes.length||t.node.childNodes[t.offset].contentEditable=="false")}function $b(t,e){let n=t.observer.selectionRange;if(!n.focusNode)return null;let r=db(n.focusNode,n.focusOffset),s=fb(n.focusNode,n.focusOffset),a=r||s;if(s&&r&&s.node!=r.node){let u=Ht.get(s.node);if(!u||u.isText()&&u.text!=s.node.nodeValue)a=s;else if(t.docView.lastCompositionAfterCursor){let f=Ht.get(r.node);!f||f.isText()&&f.text!=r.node.nodeValue||(a=s)}}if(t.docView.lastCompositionAfterCursor=a!=r,!a)return null;let c=e-a.offset;return{from:c,to:c+a.node.nodeValue.length,node:a.node}}function vT(t,e,n){let r=$b(t,n);if(!r)return null;let{node:s,from:a,to:c}=r,u=s.nodeValue;if(/[\n\r]/.test(u)||t.state.doc.sliceString(r.from,r.to)!=u)return null;let f=e.invertedDesc;return{range:new pi(f.mapPos(a),f.mapPos(c),a,c),text:s}}function wT(t,e){return t.nodeType!=1?0:(e&&t.childNodes[e-1].contentEditable=="false"?1:0)|(e{re.from&&(n=!0)}),n}class oh extends rc{constructor(e){super(),this.height=e}toDOM(){let e=document.createElement("div");return e.className="cm-gap",this.updateDOM(e),e}eq(e){return e.height==this.height}updateDOM(e){return e.style.height=this.height+"px",!0}get editable(){return!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}function jT(t,e,n=1){let r=t.charCategorizer(e),s=t.doc.lineAt(e),a=e-s.from;if(s.length==0)return ke.cursor(e);a==0?n=1:a==s.length&&(n=-1);let c=a,u=a;n<0?c=kn(s.text,a,!1):u=kn(s.text,a);let f=r(s.text.slice(c,u));for(;c>0;){let h=kn(s.text,c,!1);if(r(s.text.slice(h,c))!=f)break;c=h}for(;ut.defaultLineHeight*1.5){let u=t.viewState.heightOracle.textHeight,f=Math.floor((s-n.top-(t.defaultLineHeight-u)*.5)/u);a+=f*t.viewState.heightOracle.lineLength}let c=t.state.sliceDoc(n.from,n.to);return n.from+$N(c,a,t.state.tabSize)}function ch(t,e,n){let r=t.lineBlockAt(e);if(Array.isArray(r.type)){let s;for(let a of r.type){if(a.from>e)break;if(!(a.toe)return a;(!s||a.type==fn.Text&&(s.type!=a.type||(n<0?a.frome)))&&(s=a)}}return s||r}return r}function OT(t,e,n,r){let s=ch(t,e.head,e.assoc||-1),a=!r||s.type!=fn.Text||!(t.lineWrapping||s.widgetLineBreaks)?null:t.coordsAtPos(e.assoc<0&&e.head>s.from?e.head-1:e.head);if(a){let c=t.dom.getBoundingClientRect(),u=t.textDirectionAt(s.from),f=t.posAtCoords({x:n==(u==Bt.LTR)?c.right-1:c.left+1,y:(a.top+a.bottom)/2});if(f!=null)return ke.cursor(f,n?-1:1)}return ke.cursor(n?s.to:s.from,n?-1:1)}function Ib(t,e,n,r){let s=t.state.doc.lineAt(e.head),a=t.bidiSpans(s),c=t.textDirectionAt(s.from);for(let u=e,f=null;;){let h=rT(s,a,c,u,n),g=yb;if(!h){if(s.number==(n?t.state.doc.lines:1))return u;g=` +`,s=t.state.doc.line(s.number+(n?1:-1)),a=t.bidiSpans(s),h=t.visualLineSide(s,!n)}if(f){if(!f(g))return u}else{if(!r)return h;f=r(g)}u=h}}function MT(t,e,n){let r=t.state.charCategorizer(e),s=r(n);return a=>{let c=r(a);return s==ir.Space&&(s=c),s==c}}function RT(t,e,n,r){let s=e.head,a=n?1:-1;if(s==(n?t.state.doc.length:0))return ke.cursor(s,e.assoc);let c=e.goalColumn,u,f=t.contentDOM.getBoundingClientRect(),h=t.coordsAtPos(s,e.assoc||((e.empty?n:e.head==e.from)?1:-1)),g=t.documentTop;if(h)c==null&&(c=h.left-f.left),u=a<0?h.top:h.bottom;else{let A=t.viewState.lineBlockAt(s);c==null&&(c=Math.min(f.right-f.left,t.defaultCharacterWidth*(s-A.from))),u=(a<0?A.top:A.bottom)+g}let b=f.left+c,v=t.viewState.heightOracle.textHeight>>1,w=r??v;for(let A=0;;A+=v){let C=u+(w+A)*a,E=dh(t,{x:b,y:C},!1,a);if(n?C>f.bottom:Cu:O{if(e>a&&es(t)),n.from,e.head>n.from?-1:1);return r==n.from?n:ke.cursor(r,rt.viewState.docHeight)return new Pi(t.state.doc.length,-1);if(h=t.elementAtHeight(f),r==null)break;if(h.type==fn.Text){if(r<0?h.tot.viewport.to)break;let v=t.docView.coordsAt(r<0?h.from:h.to,r>0?-1:1);if(v&&(r<0?v.top<=f+a:v.bottom>=f+a))break}let b=t.viewState.heightOracle.textHeight/2;f=r>0?h.bottom+b:h.top-b}if(t.viewport.from>=h.to||t.viewport.to<=h.from){if(n)return null;if(h.type==fn.Text){let b=ET(t,s,h,c,u);return new Pi(b,b==h.from?1:-1)}}if(h.type!=fn.Text)return f<(h.top+h.bottom)/2?new Pi(h.from,1):new Pi(h.to,-1);let g=t.docView.lineAt(h.from,2);return(!g||g.length!=h.length)&&(g=t.docView.lineAt(h.from,-2)),new DT(t,c,u,t.textDirectionAt(h.from)).scanTile(g,h.from)}class DT{constructor(e,n,r,s){this.view=e,this.x=n,this.y=r,this.baseDir=s,this.line=null,this.spans=null}bidiSpansAt(e){return(!this.line||this.line.from>e||this.line.to1||r.length&&(r[0].level!=this.baseDir||r[0].to+s.from>1;t:if(c.has(C)){for(let O=1;O=a&&(j-=A),!c.has(j)){C=j;break t}}break e}c.add(C);let E=n(C),D=0;if(E)for(let O=0;O1))if(j.bottomthis.y)(!h||h.top>j.top)&&(h=j),D=-1;else{let R=j.left>this.x?this.x-j.left:j.right(A+A+C)/3)return this.y=f.bottom-1,this.scan(e,n,!0);if(h&&h.top<(A+C+C)/3)return this.y=h.top+1,this.scan(e,n,!0)}let w=(u?this.dirAt(e[g],1):this.baseDir)==Bt.LTR;return{i:g,after:this.x>(v.left+v.right)/2==w}}scanText(e,n){let r=[];for(let a=0;a{let c=r[a]-n,u=r[a+1]-n;return Ea(e.dom,c,u).getClientRects()});return s.after?new Pi(r[s.i+1],-1):new Pi(r[s.i],1)}scanTile(e,n){if(!e.length)return new Pi(n,1);if(e.children.length==1){let u=e.children[0];if(u.isText())return this.scanText(u,n);if(u.isComposite())return this.scanTile(u,n)}let r=[n];for(let u=0,f=n;u{let f=e.children[u];return f.flags&48?null:(f.dom.nodeType==1?f.dom:Ea(f.dom,0,f.length)).getClientRects()}),a=e.children[s.i],c=r[s.i];return a.isText()?this.scanText(a,c):a.isComposite()?this.scanTile(a,c):s.after?new Pi(r[s.i+1],-1):new Pi(c,1)}}const pl="￿";class _T{constructor(e,n){this.points=e,this.view=n,this.text="",this.lineSeparator=n.state.facet(St.lineSeparator)}append(e){this.text+=e}lineBreak(){this.text+=pl}readRange(e,n){if(!e)return this;let r=e.parentNode;for(let s=e;;){this.findPointBefore(r,s);let a=this.text.length;this.readNode(s);let c=Ht.get(s),u=s.nextSibling;if(u==n){c?.breakAfter&&!u&&r!=this.view.contentDOM&&this.lineBreak();break}let f=Ht.get(u);(c&&f?c.breakAfter:(c?c.breakAfter:lc(s))||lc(u)&&(s.nodeName!="BR"||c?.isWidget())&&this.text.length>a)&&!qT(u,n)&&this.lineBreak(),s=u}return this.findPointBefore(r,n),this}readTextNode(e){let n=e.nodeValue;for(let r of this.points)r.node==e&&(r.pos=this.text.length+Math.min(r.offset,n.length));for(let r=0,s=this.lineSeparator?null:/\r\n?|\n/g;;){let a=-1,c=1,u;if(this.lineSeparator?(a=n.indexOf(this.lineSeparator,r),c=this.lineSeparator.length):(u=s.exec(n))&&(a=u.index,c=u[0].length),this.append(n.slice(r,a<0?n.length:a)),a<0)break;if(this.lineBreak(),c>1)for(let f of this.points)f.node==e&&f.pos>this.text.length&&(f.pos-=c-1);r=a+c}}readNode(e){let n=Ht.get(e),r=n&&n.overrideDOMText;if(r!=null){this.findPointInside(e,r.length);for(let s=r.iter();!s.next().done;)s.lineBreak?this.lineBreak():this.append(s.value)}else e.nodeType==3?this.readTextNode(e):e.nodeName=="BR"?e.nextSibling&&this.lineBreak():e.nodeType==1&&this.readRange(e.firstChild,null)}findPointBefore(e,n){for(let r of this.points)r.node==e&&e.childNodes[r.offset]==n&&(r.pos=this.text.length)}findPointInside(e,n){for(let r of this.points)(e.nodeType==3?r.node==e:e.contains(r.node))&&(r.pos=this.text.length+(LT(e,r.node,r.offset)?n:0))}}function LT(t,e,n){for(;;){if(!e||n-1;let{impreciseHead:a,impreciseAnchor:c}=e.docView,u=e.state.selection;if(e.state.readOnly&&n>-1)this.newSel=null;else if(n>-1&&(this.bounds=Ub(e.docView.tile,n,r,0))){let f=a||c?[]:IT(e),h=new _T(f,e);h.readRange(this.bounds.startDOM,this.bounds.endDOM),this.text=h.text,this.newSel=HT(f,this.bounds.from)}else{let f=e.observer.selectionRange,h=a&&a.node==f.focusNode&&a.offset==f.focusOffset||!Gf(e.contentDOM,f.focusNode)?u.main.head:e.docView.posFromDOM(f.focusNode,f.focusOffset),g=c&&c.node==f.anchorNode&&c.offset==f.anchorOffset||!Gf(e.contentDOM,f.anchorNode)?u.main.anchor:e.docView.posFromDOM(f.anchorNode,f.anchorOffset),b=e.viewport;if((Oe.ios||Oe.chrome)&&h!=g&&Math.min(h,g)<=u.main.from&&Math.max(h,g)>=u.main.to&&(b.from>0||b.to-1&&u.ranges.length>1)this.newSel=u.replaceRange(ke.range(g,h));else if(e.lineWrapping&&g==h&&!(u.main.empty&&u.main.head==h)&&e.inputState.lastTouchTime>Date.now()-100){let v=e.coordsAtPos(h,-1),w=0;v&&(w=e.inputState.lastTouchY<=v.bottom?-1:1),this.newSel=ke.create([ke.cursor(h,w)])}else this.newSel=ke.single(g,h)}}}function Ub(t,e,n,r){if(t.isComposite()){let s=-1,a=-1,c=-1,u=-1;for(let f=0,h=r,g=r;fn)return Ub(b,e,n,h);if(v>=e&&s==-1&&(s=f,a=h),h>n&&b.dom.parentNode==t.dom){c=f,u=g;break}g=v,h=v+b.breakAfter}return{from:a,to:u<0?r+t.length:u,startDOM:(s?t.children[s-1].dom.nextSibling:null)||t.dom.firstChild,endDOM:c=0?t.children[c].dom:null}}else return t.isText()?{from:r,to:r+t.length,startDOM:t.dom,endDOM:t.dom.nextSibling}:null}function Vb(t,e){let n,{newSel:r}=e,{state:s}=t,a=s.selection.main,c=t.inputState.lastKeyTime>Date.now()-100?t.inputState.lastKeyCode:-1;if(e.bounds){let{from:u,to:f}=e.bounds,h=a.from,g=null;(c===8||Oe.android&&e.text.length=u&&a.to<=f&&(e.typeOver||b!=e.text)&&b.slice(0,a.from-u)==e.text.slice(0,a.from-u)&&b.slice(a.to-u)==e.text.slice(v=e.text.length-(b.length-(a.to-u)))?n={from:a.from,to:a.to,insert:mt.of(e.text.slice(a.from-u,v).split(pl))}:(w=Fb(b,e.text,h-u,g))&&(Oe.chrome&&c==13&&w.toB==w.from+2&&e.text.slice(w.from,w.toB)==pl+pl&&w.toB--,n={from:u+w.from,to:u+w.toA,insert:mt.of(e.text.slice(w.from,w.toB).split(pl))})}else r&&(!t.hasFocus&&s.facet(sr)||mc(r,a))&&(r=null);if(!n&&!r)return!1;if((Oe.mac||Oe.android)&&n&&n.from==n.to&&n.from==a.head-1&&/^\. ?$/.test(n.insert.toString())&&t.contentDOM.getAttribute("autocorrect")=="off"?(r&&n.insert.length==2&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:n.from,to:n.to,insert:mt.of([n.insert.toString().replace("."," ")])}):s.doc.lineAt(a.from).toDate.now()-50?n={from:a.from,to:a.to,insert:s.toText(t.inputState.insertingText)}:Oe.chrome&&n&&n.from==n.to&&n.from==a.head&&n.insert.toString()==` + `&&t.lineWrapping&&(r&&(r=ke.single(r.main.anchor-1,r.main.head-1)),n={from:a.from,to:a.to,insert:mt.of([" "])}),n)return fh(t,n,r,c);if(r&&!mc(r,a)){let u=!1,f="select";return t.inputState.lastSelectionTime>Date.now()-50&&(t.inputState.lastSelectionOrigin=="select"&&(u=!0),f=t.inputState.lastSelectionOrigin,f=="select.pointer"&&(r=Hb(s.facet(Oa).map(h=>h(t)),r))),t.dispatch({selection:r,scrollIntoView:u,userEvent:f}),!0}else return!1}function fh(t,e,n,r=-1){if(Oe.ios&&t.inputState.flushIOSKey(e))return!0;let s=t.state.selection.main;if(Oe.android&&(e.to==s.to&&(e.from==s.from||e.from==s.from-1&&t.state.sliceDoc(e.from,s.from)==" ")&&e.insert.length==1&&e.insert.lines==2&&cl(t.contentDOM,"Enter",13)||(e.from==s.from-1&&e.to==s.to&&e.insert.length==0||r==8&&e.insert.lengths.head)&&cl(t.contentDOM,"Backspace",8)||e.from==s.from&&e.to==s.to+1&&e.insert.length==0&&cl(t.contentDOM,"Delete",46)))return!0;let a=e.insert.toString();t.inputState.composing>=0&&t.inputState.composing++;let c,u=()=>c||(c=$T(t,e,n));return t.state.facet(Sb).some(f=>f(t,e.from,e.to,a,u))||t.dispatch(u()),!0}function $T(t,e,n){let r,s=t.state,a=s.selection.main,c=-1;if(e.from==e.to&&e.froma.to){let f=e.fromb(t)),h,f);e.from==g&&(c=g)}if(c>-1)r={changes:e,selection:ke.cursor(e.from+e.insert.length,-1)};else if(e.from>=a.from&&e.to<=a.to&&e.to-e.from>=(a.to-a.from)/3&&(!n||n.main.empty&&n.main.from==e.from+e.insert.length)&&t.inputState.composing<0){let f=a.frome.to?s.sliceDoc(e.to,a.to):"";r=s.replaceSelection(t.state.toText(f+e.insert.sliceString(0,void 0,t.state.lineBreak)+h))}else{let f=s.changes(e),h=n&&n.main.to<=f.newLength?n.main:void 0;if(s.selection.ranges.length>1&&(t.inputState.composing>=0||t.inputState.compositionPendingChange)&&e.to<=a.to+10&&e.to>=a.to-10){let g=t.state.sliceDoc(e.from,e.to),b,v=n&&$b(t,n.main.head);if(v){let A=e.insert.length-(e.to-e.from);b={from:v.from,to:v.to-A}}else b=t.state.doc.lineAt(a.head);let w=a.to-e.to;r=s.changeByRange(A=>{if(A.from==a.from&&A.to==a.to)return{changes:f,range:h||A.map(f)};let C=A.to-w,E=C-g.length;if(t.state.sliceDoc(E,C)!=g||C>=b.from&&E<=b.to)return{range:A};let D=s.changes({from:E,to:C,insert:e.insert}),O=A.to-a.to;return{changes:D,range:h?ke.range(Math.max(0,h.anchor+O),Math.max(0,h.head+O)):A.map(D)}})}else r={changes:f,selection:h&&s.selection.replaceRange(h)}}let u="input.type";return(t.composing||t.inputState.compositionPendingChange&&t.inputState.compositionEndedAt>Date.now()-50)&&(t.inputState.compositionPendingChange=!1,u+=".compose",t.inputState.compositionFirstChange&&(u+=".start",t.inputState.compositionFirstChange=!1)),s.update(r,{userEvent:u,scrollIntoView:!0})}function Fb(t,e,n,r){let s=Math.min(t.length,e.length),a=0;for(;a0&&u>0&&t.charCodeAt(c-1)==e.charCodeAt(u-1);)c--,u--;if(r=="end"){let f=Math.max(0,a-Math.min(c,u));n-=c+f-a}if(c=c?a-n:0;a-=f,u=a+(u-c),c=a}else if(u=u?a-n:0;a-=f,c=a+(c-u),u=a}return{from:a,toA:c,toB:u}}function IT(t){let e=[];if(t.root.activeElement!=t.contentDOM)return e;let{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}=t.observer.selectionRange;return n&&(e.push(new zb(n,r)),(s!=n||a!=r)&&e.push(new zb(s,a))),e}function HT(t,e){if(t.length==0)return null;let n=t[0].pos,r=t.length==2?t[1].pos:n;return n>-1&&r>-1?ke.single(n+e,r+e):null}function mc(t,e){return e.head==t.main.head&&e.anchor==t.main.anchor}class zT{setSelectionOrigin(e){this.lastSelectionOrigin=e,this.lastSelectionTime=Date.now()}constructor(e){this.view=e,this.lastKeyCode=0,this.lastKeyTime=0,this.touchActive=!1,this.lastTouchTime=0,this.lastTouchX=0,this.lastTouchY=0,this.lastFocusTime=0,this.lastScrollTop=0,this.lastScrollLeft=0,this.lastWheelEvent=0,this.pendingIOSKey=void 0,this.lastIOSMomentumScroll=0,this.tabFocusMode=-1,this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastContextMenu=0,this.scrollHandlers=[],this.handlers=Object.create(null),this.composing=-1,this.compositionFirstChange=null,this.compositionEndedAt=0,this.compositionPendingKey=!1,this.compositionPendingChange=!1,this.insertingText="",this.insertingTextAt=0,this.mouseSelection=null,this.draggedContent=null,this.handleEvent=this.handleEvent.bind(this),this.notifiedFocused=e.hasFocus,Oe.safari&&e.contentDOM.addEventListener("input",()=>null),Oe.gecko&&ij(e.contentDOM.ownerDocument)}handleEvent(e){!JT(this.view,e)||this.ignoreDuringComposition(e)||e.type=="keydown"&&this.keydown(e)||(this.view.updateState!=0?Promise.resolve().then(()=>this.runHandlers(e.type,e)):this.runHandlers(e.type,e))}runHandlers(e,n){let r=this.handlers[e];if(r){for(let s of r.observers)s(this.view,n);for(let s of r.handlers){if(n.defaultPrevented)break;if(s(this.view,n)){n.preventDefault();break}}}}ensureHandlers(e){let n=VT(e),r=this.handlers,s=this.view.contentDOM;for(let a in n)if(a!="scroll"){let c=!n[a].handlers.length,u=r[a];u&&c!=!u.handlers.length&&(s.removeEventListener(a,this.handleEvent),u=null),u||s.addEventListener(a,this.handleEvent,{passive:c})}for(let a in r)a!="scroll"&&!n[a]&&s.removeEventListener(a,this.handleEvent);this.handlers=n}keydown(e){if(this.lastKeyCode=e.keyCode,this.lastKeyTime=Date.now(),e.keyCode==9&&this.tabFocusMode>-1&&(!this.tabFocusMode||Date.now()<=this.tabFocusMode))return!0;if(this.tabFocusMode>0&&e.keyCode!=27&&Kb.indexOf(e.keyCode)<0&&(this.tabFocusMode=-1),Oe.android&&Oe.chrome&&!e.synthetic&&(e.keyCode==13||e.keyCode==8))return this.view.observer.delayAndroidKey(e.key,e.keyCode),!0;if(Oe.ios&&!e.synthetic&&!e.altKey&&!e.metaKey&&(Yb.some(n=>n.keyCode==e.keyCode)&&!e.ctrlKey||FT.indexOf(e.key)>-1&&e.ctrlKey)){let n={ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey,shiftKey:e.shiftKey};return n.shiftKey&&Oe.ios&&!/^(off|none)$/.test(this.view.contentDOM.autocapitalize)&&UT(this.view.win)&&(n.shiftKey=!1),this.pendingIOSKey={key:e.key,keyCode:e.keyCode,mods:n},setTimeout(()=>this.flushIOSKey(),50),!0}return e.keyCode!=229&&this.view.observer.forceFlush(),!1}flushIOSKey(e){let n=this.pendingIOSKey;return!n||this.view.observer.pendingRecords().length||n.key=="Enter"&&e&&e.from0?!0:Oe.safari&&!Oe.ios&&this.compositionPendingKey&&Date.now()-this.compositionEndedAt<100?(this.compositionPendingKey=!1,!0):!1}startMouseSelection(e){this.mouseSelection&&this.mouseSelection.destroy(),this.mouseSelection=e}update(e){this.view.observer.update(e),this.mouseSelection&&this.mouseSelection.update(e),this.draggedContent&&e.docChanged&&(this.draggedContent=this.draggedContent.map(e.changes)),e.transactions.length&&(this.lastKeyCode=this.lastSelectionTime=0)}destroy(){this.mouseSelection&&this.mouseSelection.destroy()}}function UT(t){return t.visualViewport?t.visualViewport.height*t.visualViewport.scale/t.document.documentElement.clientHeight<.85:!1}function Pb(t,e){return(n,r)=>{try{return e.call(t,r,n)}catch(s){Fi(n.state,s)}}}function VT(t){let e=Object.create(null);function n(r){return e[r]||(e[r]={observers:[],handlers:[]})}for(let r of t){let s=r.spec,a=s&&s.plugin.domEventHandlers,c=s&&s.plugin.domEventObservers;if(a)for(let u in a){let f=a[u];f&&n(u).handlers.push(Pb(r.value,f))}if(c)for(let u in c){let f=c[u];f&&n(u).observers.push(Pb(r.value,f))}}for(let r in Mi)n(r).handlers.push(Mi[r]);for(let r in _n)n(r).observers.push(_n[r]);return e}const Yb=[{key:"Backspace",keyCode:8,inputType:"deleteContentBackward"},{key:"Enter",keyCode:13,inputType:"insertParagraph"},{key:"Enter",keyCode:13,inputType:"insertLineBreak"},{key:"Delete",keyCode:46,inputType:"deleteContentForward"}],FT="dthko",Kb=[16,17,18,20,91,92,224,225],gc=6;function yc(t){return Math.max(0,t)*.7+8}function PT(t,e){return Math.max(Math.abs(t.clientX-e.clientX),Math.abs(t.clientY-e.clientY))}class YT{constructor(e,n,r,s){this.view=e,this.startEvent=n,this.style=r,this.mustSelect=s,this.scrollSpeed={x:0,y:0},this.scrolling=-1,this.lastEvent=n,this.scrollParents=sb(e.contentDOM),this.atoms=e.state.facet(Oa).map(c=>c(e));let a=e.contentDOM.ownerDocument;a.addEventListener("mousemove",this.move=this.move.bind(this)),a.addEventListener("mouseup",this.up=this.up.bind(this)),this.extend=n.shiftKey,this.multiple=e.state.facet(St.allowMultipleSelections)&&KT(e,n),this.dragging=XT(e,n)&&ex(n)==1?null:!1}start(e){this.dragging===!1&&this.select(e)}move(e){if(e.buttons==0)return this.destroy();if(this.dragging||this.dragging==null&&PT(this.startEvent,e)<10)return;this.select(this.lastEvent=e);let n=0,r=0,s=0,a=0,c=this.view.win.innerWidth,u=this.view.win.innerHeight;this.scrollParents.x&&({left:s,right:c}=this.scrollParents.x.getBoundingClientRect()),this.scrollParents.y&&({top:a,bottom:u}=this.scrollParents.y.getBoundingClientRect());let f=Db(this.view);e.clientX-f.left<=s+gc?n=-yc(s-e.clientX):e.clientX+f.right>=c-gc&&(n=yc(e.clientX-c)),e.clientY-f.top<=a+gc?r=-yc(a-e.clientY):e.clientY+f.bottom>=u-gc&&(r=yc(e.clientY-u)),this.setScrollSpeed(n,r)}up(e){this.dragging==null&&this.select(this.lastEvent),this.dragging||e.preventDefault(),this.destroy()}destroy(){this.setScrollSpeed(0,0);let e=this.view.contentDOM.ownerDocument;e.removeEventListener("mousemove",this.move),e.removeEventListener("mouseup",this.up),this.view.inputState.mouseSelection=this.view.inputState.draggedContent=null}setScrollSpeed(e,n){this.scrollSpeed={x:e,y:n},e||n?this.scrolling<0&&(this.scrolling=setInterval(()=>this.scroll(),50)):this.scrolling>-1&&(clearInterval(this.scrolling),this.scrolling=-1)}scroll(){let{x:e,y:n}=this.scrollSpeed;e&&this.scrollParents.x&&(this.scrollParents.x.scrollLeft+=e,e=0),n&&this.scrollParents.y&&(this.scrollParents.y.scrollTop+=n,n=0),(e||n)&&this.view.win.scrollBy(e,n),this.dragging===!1&&this.select(this.lastEvent)}select(e){let{view:n}=this,r=Hb(this.atoms,this.style.get(e,this.extend,this.multiple));(this.mustSelect||!r.eq(n.state.selection,this.dragging===!1))&&this.view.dispatch({selection:r,userEvent:"select.pointer"}),this.mustSelect=!1}update(e){e.transactions.some(n=>n.isUserEvent("input.type"))?this.destroy():this.style.update(e)&&setTimeout(()=>this.select(this.lastEvent),20)}}function KT(t,e){let n=t.state.facet(bb);return n.length?n[0](e):Oe.mac?e.metaKey:e.ctrlKey}function GT(t,e){let n=t.state.facet(xb);return n.length?n[0](e):Oe.mac?!e.altKey:!e.ctrlKey}function XT(t,e){let{main:n}=t.state.selection;if(n.empty)return!1;let r=Na(t.root);if(!r||r.rangeCount==0)return!0;let s=r.getRangeAt(0).getClientRects();for(let a=0;a=e.clientX&&c.top<=e.clientY&&c.bottom>=e.clientY)return!0}return!1}function JT(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target,r;n!=t.contentDOM;n=n.parentNode)if(!n||n.nodeType==11||(r=Ht.get(n))&&r.isWidget()&&!r.isHidden&&r.widget.ignoreEvent(e))return!1;return!0}const Mi=Object.create(null),_n=Object.create(null),Gb=Oe.ie&&Oe.ie_version<15||Oe.ios&&Oe.webkit_version<604;function QT(t){let e=t.dom.parentNode;if(!e)return;let n=e.appendChild(document.createElement("textarea"));n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus(),setTimeout(()=>{t.focus(),n.remove(),Xb(t,n.value)},50)}function bc(t,e,n){for(let r of t.facet(e))n=r(n,t);return n}function Xb(t,e){e=bc(t.state,eh,e);let{state:n}=t,r,s=1,a=n.toText(e),c=a.lines==n.selection.ranges.length;if(hh!=null&&n.selection.ranges.every(f=>f.empty)&&hh==a.toString()){let f=-1;r=n.changeByRange(h=>{let g=n.doc.lineAt(h.from);if(g.from==f)return{range:h};f=g.from;let b=n.toText((c?a.line(s++).text:e)+n.lineBreak);return{changes:{from:g.from,insert:b},range:ke.cursor(h.from+b.length)}})}else c?r=n.changeByRange(f=>{let h=a.line(s++);return{changes:{from:f.from,to:f.to,insert:h.text},range:ke.cursor(f.from+h.length)}}):r=n.replaceSelection(a);t.dispatch(r,{userEvent:"input.paste",scrollIntoView:!0})}_n.scroll=t=>{let e=t.inputState;e.lastScrollTop=t.scrollDOM.scrollTop,e.lastScrollLeft=t.scrollDOM.scrollLeft,Oe.ios&&!e.touchActive&&(e.lastIOSMomentumScroll=Date.now())},_n.wheel=_n.mousewheel=t=>{t.inputState.lastWheelEvent=Date.now()},Mi.keydown=(t,e)=>(t.inputState.setSelectionOrigin("select"),e.keyCode==27&&t.inputState.tabFocusMode!=0&&(t.inputState.tabFocusMode=Date.now()+2e3),!1),_n.touchstart=(t,e)=>{let n=t.inputState,r=e.targetTouches[0];n.touchActive=!0,n.lastTouchTime=Date.now(),r&&(n.lastTouchX=r.clientX,n.lastTouchY=r.clientY),n.setSelectionOrigin("select.pointer")},_n.touchmove=t=>{t.inputState.setSelectionOrigin("select.pointer")},_n.touchend=(t,e)=>{t.inputState.touchActive=!1},Mi.mousedown=(t,e)=>{if(t.observer.flush(),t.inputState.lastTouchTime>Date.now()-2e3)return!1;let n=null;for(let r of t.state.facet(vb))if(n=r(t,e),n)break;if(!n&&e.button==0&&(n=ZT(t,e)),n){let r=!t.hasFocus;t.inputState.startMouseSelection(new YT(t,e,n,r)),r&&t.observer.ignore(()=>{ob(t.contentDOM);let a=t.root.activeElement;a&&!a.contains(t.contentDOM)&&a.blur()});let s=t.inputState.mouseSelection;if(s)return s.start(e),s.dragging===!1}else t.inputState.setSelectionOrigin("select.pointer");return!1};function Jb(t,e,n,r){if(r==1)return ke.cursor(e,n);if(r==2)return jT(t.state,e,n);{let s=t.docView.lineAt(e,n),a=t.state.doc.lineAt(s?s.posAtEnd:e),c=s?s.posAtStart:a.from,u=s?s.posAtEnd:a.to;return uDate.now()-400&&Math.abs(e.clientX-t.clientX)<2&&Math.abs(e.clientY-t.clientY)<2?(Wb+1)%3:1}function ZT(t,e){let n=t.posAndSideAtCoords({x:e.clientX,y:e.clientY},!1),r=ex(e),s=t.state.selection;return{update(a){a.docChanged&&(n.pos=a.changes.mapPos(n.pos),s=s.map(a.changes))},get(a,c,u){let f=t.posAndSideAtCoords({x:a.clientX,y:a.clientY},!1),h,g=Jb(t,f.pos,f.assoc,r);if(n.pos!=f.pos&&!c){let b=Jb(t,n.pos,n.assoc,r),v=Math.min(b.from,g.from),w=Math.max(b.to,g.to);g=v1&&(h=ej(s,f.pos))?h:u?s.addRange(g):ke.create([g])}}}function ej(t,e){for(let n=0;n=e)return ke.create(t.ranges.slice(0,n).concat(t.ranges.slice(n+1)),t.mainIndex==n?0:t.mainIndex-(t.mainIndex>n?1:0))}return null}Mi.dragstart=(t,e)=>{let{selection:{main:n}}=t.state;if(e.target.draggable){let s=t.docView.tile.nearest(e.target);if(s&&s.isWidget()){let a=s.posAtStart,c=a+s.length;(a>=n.to||c<=n.from)&&(n=ke.undirectionalRange(a,c))}}let{inputState:r}=t;return r.mouseSelection&&(r.mouseSelection.dragging=!0),r.draggedContent=n,e.dataTransfer&&(e.dataTransfer.setData("Text",bc(t.state,th,t.state.sliceDoc(n.from,n.to))),e.dataTransfer.effectAllowed="copyMove"),!1},Mi.dragend=t=>(t.inputState.draggedContent=null,!1);function tx(t,e,n,r){if(n=bc(t.state,eh,n),!n)return;let s=t.posAtCoords({x:e.clientX,y:e.clientY},!1),{draggedContent:a}=t.inputState,c=r&&a&>(t,e)?{from:a.from,to:a.to}:null,u={from:s,insert:n},f=t.state.changes(c?[c,u]:u);t.focus(),t.dispatch({changes:f,selection:{anchor:f.mapPos(s,-1),head:f.mapPos(s,1)},userEvent:c?"move.drop":"input.drop"}),t.inputState.draggedContent=null}Mi.drop=(t,e)=>{if(!e.dataTransfer)return!1;if(t.state.readOnly)return!0;let n=e.dataTransfer.files;if(n&&n.length){let r=Array(n.length),s=0,a=()=>{++s==n.length&&tx(t,e,r.filter(c=>c!=null).join(t.state.lineBreak),!1)};for(let c=0;c{/[\x00-\x08\x0e-\x1f]{2}/.test(u.result)||(r[c]=u.result),a()},u.readAsText(n[c])}return!0}else{let r=e.dataTransfer.getData("Text");if(r)return tx(t,e,r,!0),!0}return!1},Mi.paste=(t,e)=>{if(t.state.readOnly)return!0;t.observer.flush();let n=Gb?null:e.clipboardData;return n?(Xb(t,n.getData("text/plain")||n.getData("text/uri-list")),!0):(QT(t),!1)};function tj(t,e){let n=t.dom.parentNode;if(!n)return;let r=n.appendChild(document.createElement("textarea"));r.style.cssText="position: fixed; left: -10000px; top: 10px",r.value=e,r.focus(),r.selectionEnd=e.length,r.selectionStart=0,setTimeout(()=>{r.remove(),t.focus()},50)}function nj(t){let e=[],n=[],r=!1;for(let s of t.selection.ranges)s.empty||(e.push(t.sliceDoc(s.from,s.to)),n.push(s));if(!e.length){let s=-1;for(let{from:a}of t.selection.ranges){let c=t.doc.lineAt(a);c.number>s&&(e.push(c.text),n.push({from:c.from,to:Math.min(t.doc.length,c.to+1)})),s=c.number}r=!0}return{text:bc(t,th,e.join(t.lineBreak)),ranges:n,linewise:r}}let hh=null;Mi.copy=Mi.cut=(t,e)=>{if(!Ta(t.contentDOM,t.observer.selectionRange))return!1;let{text:n,ranges:r,linewise:s}=nj(t.state);if(!n&&!s)return!1;hh=s?n:null,e.type=="cut"&&!t.state.readOnly&&t.dispatch({changes:r,scrollIntoView:!0,userEvent:"delete.cut"});let a=Gb?null:e.clipboardData;return a?(a.clearData(),a.setData("text/plain",n),!0):(tj(t,n),!1)};const nx=Br.define();function ix(t,e){let n=[];for(let r of t.facet(Ab)){let s=r(t,e);s&&n.push(s)}return n.length?t.update({effects:n,annotations:nx.of(!0)}):null}function rx(t){setTimeout(()=>{let e=t.hasFocus;if(e!=t.inputState.notifiedFocused){let n=ix(t.state,e);n?t.dispatch(n):t.update([])}},10)}_n.focus=t=>{t.inputState.lastFocusTime=Date.now(),!t.scrollDOM.scrollTop&&(t.inputState.lastScrollTop||t.inputState.lastScrollLeft)&&(t.scrollDOM.scrollTop=t.inputState.lastScrollTop,t.scrollDOM.scrollLeft=t.inputState.lastScrollLeft),rx(t)},_n.blur=t=>{t.observer.clearSelectionRange(),rx(t)},_n.compositionstart=_n.compositionupdate=t=>{t.observer.editContext||(t.inputState.compositionFirstChange==null&&(t.inputState.compositionFirstChange=!0),t.inputState.composing<0&&(t.inputState.composing=0))},_n.compositionend=t=>{t.observer.editContext||(t.inputState.composing=-1,t.inputState.compositionEndedAt=Date.now(),t.inputState.compositionPendingKey=!0,t.inputState.compositionPendingChange=t.observer.pendingRecords().length>0,t.inputState.compositionFirstChange=null,Oe.chrome&&Oe.android?t.observer.flushSoon():t.inputState.compositionPendingChange?Promise.resolve().then(()=>t.observer.flush()):setTimeout(()=>{t.inputState.composing<0&&t.docView.hasComposition&&t.update([])},50))},_n.contextmenu=t=>{t.inputState.lastContextMenu=Date.now()},Mi.beforeinput=(t,e)=>{var n,r;if((e.inputType=="insertText"||e.inputType=="insertCompositionText")&&(t.inputState.insertingText=e.data,t.inputState.insertingTextAt=Date.now()),e.inputType=="insertReplacementText"&&t.observer.editContext){let a=(n=e.dataTransfer)===null||n===void 0?void 0:n.getData("text/plain"),c=e.getTargetRanges();if(a&&c.length){let u=c[0],f=t.posAtDOM(u.startContainer,u.startOffset),h=t.posAtDOM(u.endContainer,u.endOffset);return fh(t,{from:f,to:h,insert:t.state.toText(a)},null),!0}}let s;if(Oe.chrome&&Oe.android&&(s=Yb.find(a=>a.inputType==e.inputType))&&(t.observer.delayAndroidKey(s.key,s.keyCode),s.key=="Backspace"||s.key=="Delete")){let a=((r=window.visualViewport)===null||r===void 0?void 0:r.height)||0;setTimeout(()=>{var c;(((c=window.visualViewport)===null||c===void 0?void 0:c.height)||0)>a+10&&t.hasFocus&&(t.contentDOM.blur(),t.focus())},100)}return Oe.ios&&e.inputType=="deleteContentForward"&&t.observer.flushSoon(),Oe.safari&&e.inputType=="insertText"&&t.inputState.composing>=0&&setTimeout(()=>_n.compositionend(t,e),20),!1};const sx=new Set;function ij(t){sx.has(t)||(sx.add(t),t.addEventListener("copy",()=>{}),t.addEventListener("cut",()=>{}))}const lx=["pre-wrap","normal","pre-line","break-spaces"];let ml=!1;function ax(){ml=!1}class rj{constructor(e){this.lineWrapping=e,this.doc=mt.empty,this.heightSamples={},this.lineHeight=14,this.charWidth=7,this.textHeight=14,this.lineLength=30}heightForGap(e,n){let r=this.doc.lineAt(n).number-this.doc.lineAt(e).number+1;return this.lineWrapping&&(r+=Math.max(0,Math.ceil((n-e-r*this.lineLength*.5)/this.lineLength))),this.lineHeight*r}heightForLine(e){return this.lineWrapping?(1+Math.max(0,Math.ceil((e-this.lineLength)/Math.max(1,this.lineLength-5))))*this.lineHeight:this.lineHeight}setDoc(e){return this.doc=e,this}mustRefreshForWrapping(e){return lx.indexOf(e)>-1!=this.lineWrapping}mustRefreshForHeights(e){let n=!1;for(let r=0;r-1,f=Math.abs(n-this.lineHeight)>.3||this.lineWrapping!=u;if(this.lineWrapping=u,this.lineHeight=n,this.charWidth=r,this.textHeight=s,this.lineLength=a,f){this.heightSamples={};for(let h=0;h0}set outdated(e){this.flags=(e?2:0)|this.flags&-3}setHeight(e){this.height!=e&&(Math.abs(this.height-e)>xc&&(ml=!0),this.height=e)}replace(e,n,r){return Ln.of(r)}decomposeLeft(e,n){n.push(this)}decomposeRight(e,n){n.push(this)}applyChanges(e,n,r,s){let a=this,c=r.doc;for(let u=s.length-1;u>=0;u--){let{fromA:f,toA:h,fromB:g,toB:b}=s[u],v=a.lineAt(f,Rt.ByPosNoHeight,r.setDoc(n),0,0),w=v.to>=h?v:a.lineAt(h,Rt.ByPosNoHeight,r,0,0);for(b+=w.to-h,h=w.to;u>0&&v.from<=s[u-1].toA;)f=s[u-1].fromA,g=s[u-1].fromB,u--,fa*2){let u=e[n-1];u.break?e.splice(--n,1,u.left,null,u.right):e.splice(--n,1,u.left,u.right),r+=1+u.break,s-=u.size}else if(a>s*2){let u=e[r];u.break?e.splice(r,1,u.left,null,u.right):e.splice(r,1,u.left,u.right),r+=2+u.break,a-=u.size}else break;else if(s=a&&c(this.lineAt(0,Rt.ByPos,r,s,a))}setMeasuredHeight(e){let n=e.heights[e.index++];n<0?(this.spaceAbove=-n,n=e.heights[e.index++]):this.spaceAbove=0,this.setHeight(n)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more&&this.setMeasuredHeight(s),this.outdated=!1,this}toString(){return`block(${this.length})`}}class Zn extends ox{constructor(e,n,r){super(e,n,null),this.collapsed=0,this.widgetHeight=0,this.breaks=0,this.spaceAbove=r}mainBlock(e,n){return new Ri(n,this.length,e+this.spaceAbove,this.height-this.spaceAbove,this.breaks)}replace(e,n,r){let s=r[0];return r.length==1&&(s instanceof Zn||s instanceof hn&&s.flags&4)&&Math.abs(this.length-s.length)<10?(s instanceof hn?s=new Zn(s.length,this.height,this.spaceAbove):s.height=this.height,this.outdated||(s.outdated=!1),s):Ln.of(r)}updateHeight(e,n=0,r=!1,s){return s&&s.from<=n&&s.more?this.setMeasuredHeight(s):(r||this.outdated)&&(this.spaceAbove=0,this.setHeight(Math.max(this.widgetHeight,e.heightForLine(this.length-this.collapsed))+this.breaks*e.lineHeight)),this.outdated=!1,this}toString(){return`line(${this.length}${this.collapsed?-this.collapsed:""}${this.widgetHeight?":"+this.widgetHeight:""})`}}class hn extends Ln{constructor(e){super(e,0)}heightMetrics(e,n){let r=e.doc.lineAt(n).number,s=e.doc.lineAt(n+this.length).number,a=s-r+1,c,u=0;if(e.lineWrapping){let f=Math.min(this.height,e.lineHeight*a);c=f/a,this.length>a+1&&(u=(this.height-f)/(this.length-a-1))}else c=this.height/a;return{firstLine:r,lastLine:s,perLine:c,perChar:u}}blockAt(e,n,r,s){let{firstLine:a,lastLine:c,perLine:u,perChar:f}=this.heightMetrics(n,s);if(n.lineWrapping){let h=s+(e0){let a=r[r.length-1];a instanceof hn?r[r.length-1]=new hn(a.length+s):r.push(null,new hn(s-1))}if(e>0){let a=r[0];a instanceof hn?r[0]=new hn(e+a.length):r.unshift(new hn(e-1),null)}return Ln.of(r)}decomposeLeft(e,n){n.push(new hn(e-1),null)}decomposeRight(e,n){n.push(null,new hn(this.length-e-1))}updateHeight(e,n=0,r=!1,s){let a=n+this.length;if(s&&s.from<=n+this.length&&s.more){let c=[],u=Math.max(n,s.from),f=-1;for(s.from>n&&c.push(new hn(s.from-n-1).updateHeight(e,n));u<=a&&s.more;){let g=e.doc.lineAt(u).length;c.length&&c.push(null);let b=s.heights[s.index++],v=0;b<0&&(v=-b,b=s.heights[s.index++]),f==-1?f=b:Math.abs(b-f)>=xc&&(f=-2);let w=new Zn(g,b,v);w.outdated=!1,c.push(w),u+=g+1}u<=a&&c.push(null,new hn(a-u).updateHeight(e,u));let h=Ln.of(c);return(f<0||Math.abs(h.height-this.height)>=xc||Math.abs(f-this.heightMetrics(e,n).perLine)>=xc)&&(ml=!0),vc(this,h)}else(r||this.outdated)&&(this.setHeight(e.heightForGap(n,n+this.length)),this.outdated=!1);return this}toString(){return`gap(${this.length})`}}class aj extends Ln{constructor(e,n,r){super(e.length+n+r.length,e.height+r.height,n|(e.outdated||r.outdated?2:0)),this.left=e,this.right=r,this.size=e.size+r.size}get break(){return this.flags&1}blockAt(e,n,r,s){let a=r+this.left.height;return eu))return h;let g=n==Rt.ByPosNoHeight?Rt.ByPosNoHeight:Rt.ByPos;return f?h.join(this.right.lineAt(u,g,r,c,u)):this.left.lineAt(u,g,r,s,a).join(h)}forEachLine(e,n,r,s,a,c){let u=s+this.left.height,f=a+this.left.length+this.break;if(this.break)e=f&&this.right.forEachLine(e,n,r,u,f,c);else{let h=this.lineAt(f,Rt.ByPos,r,s,a);e=e&&h.from<=n&&c(h),n>h.to&&this.right.forEachLine(h.to+1,n,r,u,f,c)}}replace(e,n,r){let s=this.left.length+this.break;if(nthis.left.length)return this.balanced(this.left,this.right.replace(e-s,n-s,r));let a=[];e>0&&this.decomposeLeft(e,a);let c=a.length;for(let u of r)a.push(u);if(e>0&&cx(a,c-1),n=r&&n.push(null)),e>r&&this.right.decomposeLeft(e-r,n)}decomposeRight(e,n){let r=this.left.length,s=r+this.break;if(e>=s)return this.right.decomposeRight(e-s,n);e2*n.size||n.size>2*e.size?Ln.of(this.break?[e,null,n]:[e,n]):(this.left=vc(this.left,e),this.right=vc(this.right,n),this.setHeight(e.height+n.height),this.outdated=e.outdated||n.outdated,this.size=e.size+n.size,this.length=e.length+this.break+n.length,this)}updateHeight(e,n=0,r=!1,s){let{left:a,right:c}=this,u=n+a.length+this.break,f=null;return s&&s.from<=n+a.length&&s.more?f=a=a.updateHeight(e,n,r,s):a.updateHeight(e,n,r),s&&s.from<=u+c.length&&s.more?f=c=c.updateHeight(e,u,r,s):c.updateHeight(e,u,r),f?this.balanced(a,c):(this.height=this.left.height+this.right.height,this.outdated=!1,this)}toString(){return this.left+(this.break?" ":"-")+this.right}}function cx(t,e){let n,r;t[e]==null&&(n=t[e-1])instanceof hn&&(r=t[e+1])instanceof hn&&t.splice(e-1,3,new hn(n.length+1+r.length))}const oj=5;class ph{constructor(e,n){this.pos=e,this.oracle=n,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,n){if(this.lineStart>-1){let r=Math.min(n,this.lineEnd),s=this.nodes[this.nodes.length-1];s instanceof Zn?s.length+=r-this.pos:(r>this.pos||!this.isCovered)&&this.nodes.push(new Zn(r-this.pos,-1,0)),this.writtenTo=r,n>r&&(this.nodes.push(null),this.writtenTo++,this.lineStart=-1)}this.pos=n}point(e,n,r){if(e=oj)&&this.addLineDeco(s,a,c)}else n>e&&this.span(e,n);this.lineEnd>-1&&this.lineEnd-1)return;let{from:e,to:n}=this.oracle.doc.lineAt(this.pos);this.lineStart=e,this.lineEnd=n,this.writtenToe&&this.nodes.push(new Zn(this.pos-e,-1,0)),this.writtenTo=this.pos}blankContent(e,n){let r=new hn(n-e);return this.oracle.doc.lineAt(e).to==n&&(r.flags|=4),r}ensureLine(){this.enterLine();let e=this.nodes.length?this.nodes[this.nodes.length-1]:null;if(e instanceof Zn)return e;let n=new Zn(0,-1,0);return this.nodes.push(n),n}addBlock(e){this.enterLine();let n=e.deco;n&&n.startSide>0&&!this.isCovered&&this.ensureLine(),this.nodes.push(e),this.writtenTo=this.pos=this.pos+e.length,n&&n.endSide>0&&(this.covering=e)}addLineDeco(e,n,r){let s=this.ensureLine();s.length+=r,s.collapsed+=r,s.widgetHeight=Math.max(s.widgetHeight,e),s.breaks+=n,this.writtenTo=this.pos=this.pos+r}finish(e){let n=this.nodes.length==0?null:this.nodes[this.nodes.length-1];this.lineStart>-1&&!(n instanceof Zn)&&!this.isCovered?this.nodes.push(new Zn(0,-1,0)):(this.writtenTog.clientHeight||g.scrollWidth>g.clientWidth)&&b.overflow!="visible"){let v=g.getBoundingClientRect();a=Math.max(a,v.left),c=Math.min(c,v.right),u=Math.max(u,v.top),f=Math.min(h==t.parentNode?s.innerHeight:f,v.bottom)}h=b.position=="absolute"||b.position=="fixed"?g.offsetParent:g.parentNode}else if(h.nodeType==11)h=h.host;else break;return{left:a-n.left,right:Math.max(a,c)-n.left,top:u-(n.top+e),bottom:Math.max(u,f)-(n.top+e)}}function fj(t){let e=t.getBoundingClientRect(),n=t.ownerDocument.defaultView||window;return e.left0&&e.top0}function hj(t,e){let n=t.getBoundingClientRect();return{left:0,right:n.right-n.left,top:e,bottom:n.bottom-(n.top+e)}}class mh{constructor(e,n,r,s){this.from=e,this.to=n,this.size=r,this.displaySize=s}static same(e,n){if(e.length!=n.length)return!1;for(let r=0;rtypeof s!="function"&&s.class=="cm-lineWrapping");this.heightOracle=new rj(r),this.stateDeco=fx(n),this.heightMap=Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle.setDoc(n.doc),[new pi(0,0,0,n.doc.length)]);for(let s=0;s<2&&(this.viewport=this.getViewport(0,null),!!this.updateForViewport());s++);this.updateViewportLines(),this.lineGaps=this.ensureLineGaps([]),this.lineGapDeco=ln.set(this.lineGaps.map(s=>s.draw(this,!1))),this.scrollParent=e.scrollDOM,this.computeVisibleRanges()}updateForViewport(){let e=[this.viewport],{main:n}=this.state.selection;for(let r=0;r<=1;r++){let s=r?n.head:n.anchor;if(!e.some(({from:a,to:c})=>s>=a&&s<=c)){let{from:a,to:c}=this.lineBlockAt(s);e.push(new wc(a,c))}}return this.viewports=e.sort((r,s)=>r.from-s.from),this.updateScaler()}updateScaler(){let e=this.scaler;return this.scaler=this.heightMap.height<=7e6?dx:new gh(this.heightOracle,this.heightMap,this.viewports),e.eq(this.scaler)?0:2}updateViewportLines(){this.viewportLines=[],this.heightMap.forEachLine(this.viewport.from,this.viewport.to,this.heightOracle.setDoc(this.state.doc),0,0,e=>{this.viewportLines.push(Da(e,this.scaler))})}update(e,n=null){this.state=e.state;let r=this.stateDeco;this.stateDeco=fx(this.state);let s=e.changedRanges,a=pi.extendWithRanges(s,cj(r,this.stateDeco,e?e.changes:nn.empty(this.state.doc.length))),c=this.heightMap.height,u=this.scrolledToBottom?null:this.scrollAnchorAt(this.scrollOffset);ax(),this.heightMap=this.heightMap.applyChanges(this.stateDeco,e.startState.doc,this.heightOracle.setDoc(this.state.doc),a),(this.heightMap.height!=c||ml)&&(e.flags|=2),u?(this.scrollAnchorPos=e.changes.mapPos(u.from,-1),this.scrollAnchorHeight=u.top):(this.scrollAnchorPos=-1,this.scrollAnchorHeight=c);let f=a.length?this.mapViewport(this.viewport,e.changes):this.viewport;(n&&(n.range.headf.to)||!this.viewportIsAppropriate(f))&&(f=this.getViewport(0,n));let h=f.from!=this.viewport.from||f.to!=this.viewport.to;this.viewport=f,e.flags|=this.updateForViewport(),(h||!e.changes.empty||e.flags&2)&&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(e.changes),n&&(this.scrollTarget=n),!this.mustEnforceCursorAssoc&&(e.selectionSet||e.focusChanged)&&e.view.lineWrapping&&e.state.selection.main.empty&&e.state.selection.main.assoc&&!e.state.facet(Cb)&&(this.mustEnforceCursorAssoc=!0)}measure(){let{view:e}=this,n=e.contentDOM,r=window.getComputedStyle(n),s=this.heightOracle,a=r.whiteSpace;this.defaultTextDirection=r.direction=="rtl"?Bt.RTL:Bt.LTR;let c=this.heightOracle.mustRefreshForWrapping(a)||this.mustMeasureContent==="refresh",u=n.getBoundingClientRect(),f=c||this.mustMeasureContent||this.contentDOMHeight!=u.height;this.contentDOMHeight=u.height,this.mustMeasureContent=!1;let h=0,g=0;if(u.width&&u.height){let{scaleX:_,scaleY:L}=rb(n,u);(_>.005&&Math.abs(this.scaleX-_)>.005||L>.005&&Math.abs(this.scaleY-L)>.005)&&(this.scaleX=_,this.scaleY=L,h|=16,c=f=!0)}let b=(parseInt(r.paddingTop)||0)*this.scaleY,v=(parseInt(r.paddingBottom)||0)*this.scaleY;(this.paddingTop!=b||this.paddingBottom!=v)&&(this.paddingTop=b,this.paddingBottom=v,h|=18),this.editorWidth!=e.scrollDOM.clientWidth&&(s.lineWrapping&&(f=!0),this.editorWidth=e.scrollDOM.clientWidth,h|=16);let w=sb(this.view.contentDOM,!1).y;w!=this.scrollParent&&(this.scrollParent=w,this.scrollAnchorHeight=-1,this.scrollOffset=0);let A=this.getScrollOffset();this.scrollOffset!=A&&(this.scrollAnchorHeight=-1,this.scrollOffset=A),this.scrolledToBottom=ub(this.scrollParent||e.win);let C=(this.printing?hj:dj)(n,this.paddingTop),E=C.top-this.pixelViewport.top,D=C.bottom-this.pixelViewport.bottom;this.pixelViewport=C;let O=this.pixelViewport.bottom>this.pixelViewport.top&&this.pixelViewport.right>this.pixelViewport.left;if(O!=this.inView&&(this.inView=O,O&&(f=!0)),!this.inView&&!this.scrollTarget&&!fj(e.dom))return 0;let j=u.width;if((this.contentDOMWidth!=j||this.editorHeight!=e.scrollDOM.clientHeight)&&(this.contentDOMWidth=u.width,this.editorHeight=e.scrollDOM.clientHeight,h|=16),f){let _=e.docView.measureVisibleLineHeights(this.viewport);if(s.mustRefreshForHeights(_)&&(c=!0),c||s.lineWrapping&&Math.abs(j-this.contentDOMWidth)>s.charWidth){let{lineHeight:L,charWidth:M,textHeight:G}=e.docView.measureTextSize();c=L>0&&s.refresh(a,L,M,G,Math.max(5,j/M),_),c&&(e.docView.minWidth=0,h|=16)}E>0&&D>0?g=Math.max(E,D):E<0&&D<0&&(g=Math.min(E,D)),ax();for(let L of this.viewports){let M=L.from==this.viewport.from?_:e.docView.measureVisibleLineHeights(L);this.heightMap=(c?Ln.empty().applyChanges(this.stateDeco,mt.empty,this.heightOracle,[new pi(0,0,0,e.state.doc.length)]):this.heightMap).updateHeight(s,0,c,new sj(L.from,M))}ml&&(h|=2)}let R=!this.viewportIsAppropriate(this.viewport,g)||this.scrollTarget&&(this.scrollTarget.range.headthis.viewport.to);return R&&(h&2&&(h|=this.updateScaler()),this.viewport=this.getViewport(g,this.scrollTarget),h|=this.updateForViewport()),(h&2||R)&&this.updateViewportLines(),(this.lineGaps.length||this.viewport.to-this.viewport.from>4e3)&&this.updateLineGaps(this.ensureLineGaps(c?[]:this.lineGaps,e)),h|=this.computeVisibleRanges(),this.mustEnforceCursorAssoc&&(this.mustEnforceCursorAssoc=!1,e.docView.enforceCursorAssoc()),h}get visibleTop(){return this.scaler.fromDOM(this.pixelViewport.top)}get visibleBottom(){return this.scaler.fromDOM(this.pixelViewport.bottom)}getViewport(e,n){let r=.5-Math.max(-.5,Math.min(.5,e/1e3/2)),s=this.heightMap,a=this.heightOracle,{visibleTop:c,visibleBottom:u}=this,f=new wc(s.lineAt(c-r*1e3,Rt.ByHeight,a,0,0).from,s.lineAt(u+(1-r)*1e3,Rt.ByHeight,a,0,0).to);if(n){let{head:h}=n.range;if(hf.to){let g=Math.min(this.editorHeight,this.pixelViewport.bottom-this.pixelViewport.top),b=s.lineAt(h,Rt.ByPos,a,0,0),v;n.y=="center"?v=(b.top+b.bottom)/2-g/2:n.y=="start"||n.y=="nearest"&&h=u+Math.max(10,Math.min(r,250)))&&s>c-2e3&&a>1,c=s<<1;if(this.defaultTextDirection!=Bt.LTR&&!r)return[];let u=[],f=(g,b,v,w)=>{if(b-gg&&DD.from>=v.from&&D.to<=v.to&&Math.abs(D.from-g)D.fromO));if(!E){if(bj.from<=b&&j.to>=b)){let j=n.moveToLineBoundary(ke.cursor(b),!1,!0).head;j>g&&(b=j)}let D=this.gapSize(v,g,b,w),O=r||D<2e6?D:2e6;E=new mh(g,b,D,O)}u.push(E)},h=g=>{if(g.length2e6)for(let L of e)L.from>=g.from&&L.fromg.from&&f(g.from,w,g,b),An.draw(this,this.heightOracle.lineWrapping))))}computeVisibleRanges(e){let n=this.stateDeco;this.lineGaps.length&&(n=n.concat(this.lineGapDeco));let r=[];pt.spans(n,this.viewport.from,this.viewport.to,{span(a,c){r.push({from:a,to:c})},point(){}},20);let s=0;if(r.length!=this.visibleRanges.length)s=12;else for(let a=0;a=this.viewport.from&&e<=this.viewport.to&&this.viewportLines.find(n=>n.from<=e&&n.to>=e)||Da(this.heightMap.lineAt(e,Rt.ByPos,this.heightOracle,0,0),this.scaler)}lineBlockAtHeight(e){return e>=this.viewportLines[0].top&&e<=this.viewportLines[this.viewportLines.length-1].bottom&&this.viewportLines.find(n=>n.top<=e&&n.bottom>=e)||Da(this.heightMap.lineAt(this.scaler.fromDOM(e),Rt.ByHeight,this.heightOracle,0,0),this.scaler)}getScrollOffset(){return this.scrollParent==this.view.scrollDOM?this.scrollParent.scrollTop*this.scaleY:(this.scrollParent?this.scrollParent.getBoundingClientRect().top:0)-this.view.contentDOM.getBoundingClientRect().top}scrollAnchorAt(e){let n=this.lineBlockAtHeight(e+8);return n.from>=this.viewport.from||this.viewportLines[0].top-e>200?n:this.viewportLines[0]}elementAtHeight(e){return Da(this.heightMap.blockAt(this.scaler.fromDOM(e),this.heightOracle,0,0),this.scaler)}get docHeight(){return this.scaler.toDOM(this.heightMap.height)}get contentHeight(){return this.docHeight+this.paddingTop+this.paddingBottom}}class wc{constructor(e,n){this.from=e,this.to=n}}function mj(t,e,n){let r=[],s=t,a=0;return pt.spans(n,t,e,{span(){},point(c,u){c>s&&(r.push({from:s,to:c}),a+=c-s),s=u}},20),s=1)return e[e.length-1].to;let r=Math.floor(t*n);for(let s=0;;s++){let{from:a,to:c}=e[s],u=c-a;if(r<=u)return a+r;r-=u}}function Ac(t,e){let n=0;for(let{from:r,to:s}of t.ranges){if(e<=s){n+=e-r;break}n+=s-r}return n/t.total}function gj(t,e){for(let n of t)if(e(n))return n}const dx={toDOM(t){return t},fromDOM(t){return t},scale:1,eq(t){return t==this}};function fx(t){let e=t.facet(cc).filter(r=>typeof r!="function"),n=t.facet(rh).filter(r=>typeof r!="function");return n.length&&e.push(pt.join(n)),e}class gh{constructor(e,n,r){let s=0,a=0,c=0;this.viewports=r.map(({from:u,to:f})=>{let h=n.lineAt(u,Rt.ByPos,e,0,0).top,g=n.lineAt(f,Rt.ByPos,e,0,0).bottom;return s+=g-h,{from:u,to:f,top:h,bottom:g,domTop:0,domBottom:0}}),this.scale=(7e6-s)/(n.height-s);for(let u of this.viewports)u.domTop=c+(u.top-a)*this.scale,c=u.domBottom=u.domTop+(u.bottom-u.top),a=u.bottom}toDOM(e){for(let n=0,r=0,s=0;;n++){let a=nn.from==e.viewports[r].from&&n.to==e.viewports[r].to):!1}}function Da(t,e){if(e.scale==1)return t;let n=e.toDOM(t.top),r=e.toDOM(t.bottom);return new Ri(t.from,t.length,n,r-n,Array.isArray(t._content)?t._content.map(s=>Da(s,e)):t._content)}const kc=Ue.define({combine:t=>t.join(" ")}),yh=Ue.define({combine:t=>t.indexOf(!0)>-1}),bh=al.newName(),hx=al.newName(),px=al.newName(),mx={"&light":"."+hx,"&dark":"."+px};function xh(t,e,n){return new al(e,{finish(r){return/&/.test(r)?r.replace(/&\w*/,s=>{if(s=="&")return t;if(!n||!n[s])throw new RangeError(`Unsupported selector: ${s}`);return n[s]}):t+" "+r}})}const yj=xh("."+bh,{"&":{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,overflowAnchor:"none"},".cm-content":{margin:0,flexGrow:2,flexShrink:0,display:"block",whiteSpace:"pre",wordWrap:"normal",boxSizing:"border-box",minHeight:"100%",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 6px"},".cm-layer":{userSelect:"none",position:"absolute",left:0,top:0,contain:"size style","& > *":{position:"absolute"}},"&light .cm-selectionBackground":{background:"#d9d9d9"},"&dark .cm-selectionBackground":{background:"#222"},"&light.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#d7d4f0"},"&dark.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground":{background:"#233"},".cm-cursorLayer":{pointerEvents:"none"},"&.cm-focused > .cm-scroller > .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":{borderLeft:"1.2px solid black",marginLeft:"-0.6px",pointerEvents:"none"},".cm-cursor":{display:"none"},"&dark .cm-cursor":{borderLeftColor:"#ddd"},".cm-selectionHandle":{backgroundColor:"currentColor",width:"1.5px"},".cm-selectionHandle-start::before, .cm-selectionHandle-end::before":{content:'""',backgroundColor:"inherit",borderRadius:"50%",width:"8px",height:"8px",position:"absolute",left:"-3.25px"},".cm-selectionHandle-start::before":{top:"-8px"},".cm-selectionHandle-end::before":{bottom:"-8px"},".cm-dropCursor":{position:"absolute"},"&.cm-focused > .cm-scroller > .cm-cursorLayer .cm-cursor":{display:"block"},".cm-iso":{unicodeBidi:"isolate"},".cm-announced":{position:"fixed",top:"-10000px"},"@media print":{".cm-announced":{display:"none"}},"&light .cm-activeLine":{backgroundColor:"#cceeff44"},"&dark .cm-activeLine":{backgroundColor:"#99eeff33"},"&light .cm-specialChar":{color:"red"},"&dark .cm-specialChar":{color:"#f78"},".cm-gutters":{flexShrink:0,display:"flex",height:"100%",boxSizing:"border-box",zIndex:200},".cm-gutters-before":{insetInlineStart:0},".cm-gutters-after":{insetInlineEnd:0},"&light .cm-gutters":{backgroundColor:"#f5f5f5",color:"#6c6c6c",border:"0px solid #ddd","&.cm-gutters-before":{borderRightWidth:"1px"},"&.cm-gutters-after":{borderLeftWidth:"1px"}},"&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,zIndex:300},"&light .cm-panels":{backgroundColor:"#f5f5f5",color:"black"},".cm-panels-top":{top:"0"},".cm-panels-bottom":{bottom:"0"},"&light .cm-panels-top":{borderBottom:"1px solid #ddd"},"&light .cm-panels-bottom":{borderTop:"1px solid #ddd"},"&dark .cm-panels":{backgroundColor:"#333338",color:"white"},".cm-dialog":{padding:"2px 19px 4px 6px",position:"relative","& label":{fontSize:"80%"}},".cm-dialog-close":{position:"absolute",top:"3px",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",fontSize:"14px",padding:"0"},".cm-tab":{display:"inline-block",overflow:"hidden",verticalAlign:"bottom"},".cm-widgetBuffer":{verticalAlign:"text-top",height:"1em",width:0,display:"inline"},".cm-placeholder":{color:"#888",display:"inline-block",verticalAlign:"top",userSelect:"none"},".cm-highlightSpace":{background:"radial-gradient(circle at 50% 55%, #aaa 20%, transparent 0) no-repeat",backgroundSize:".4em",backgroundPosition:"calc(min(50%, 0px)) center"},".cm-highlightTab":{backgroundImage:`url('data:image/svg+xml,')`,backgroundSize:"auto 100%",backgroundPosition:"right 90%",backgroundRepeat:"no-repeat"},".cm-trailingSpace":{backgroundColor:"#ff332255"},".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"}},mx),bj={childList:!0,characterData:!0,subtree:!0,attributes:!0,characterDataOldValue:!0},vh=Oe.ie&&Oe.ie_version<=11;class xj{constructor(e){this.view=e,this.active=!1,this.editContext=null,this.selectionRange=new GN,this.selectionChanged=!1,this.delayedFlush=-1,this.resizeTimeout=-1,this.queue=[],this.delayedAndroidKey=null,this.flushingAndroidKey=-1,this.lastChange=0,this.scrollTargets=[],this.intersection=null,this.resizeScroll=null,this.intersecting=!1,this.gapIntersection=null,this.gaps=[],this.printQuery=null,this.parentCheck=-1,this.dom=e.contentDOM,this.observer=new MutationObserver(n=>{for(let r of n)this.queue.push(r);(Oe.ie&&Oe.ie_version<=11||Oe.ios&&e.composing)&&n.some(r=>r.type=="childList"&&r.removedNodes.length||r.type=="characterData"&&r.oldValue.length>r.target.nodeValue.length)?this.flushSoon():this.flush()}),window.EditContext&&Oe.android&&e.constructor.EDIT_CONTEXT!==!1&&!(Oe.chrome&&Oe.chrome_version<126)&&(this.editContext=new wj(e),e.state.facet(sr)&&(e.contentDOM.editContext=this.editContext.editContext)),vh&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this),this.onResize=this.onResize.bind(this),this.onPrint=this.onPrint.bind(this),this.onScroll=this.onScroll.bind(this),window.matchMedia&&(this.printQuery=window.matchMedia("print")),typeof ResizeObserver=="function"&&(this.resizeScroll=new ResizeObserver(()=>{var n;((n=this.view.docView)===null||n===void 0?void 0:n.lastUpdate){this.parentCheck<0&&(this.parentCheck=setTimeout(this.listenForScroll.bind(this),1e3)),n.length>0&&n[n.length-1].intersectionRatio>0!=this.intersecting&&(this.intersecting=!this.intersecting,this.intersecting!=this.view.inView&&this.onScrollChanged(document.createEvent("Event")))},{threshold:[0,.001]}),this.intersection.observe(this.dom),this.gapIntersection=new IntersectionObserver(n=>{n.length>0&&n[n.length-1].intersectionRatio>0&&this.onScrollChanged(document.createEvent("Event"))},{})),this.listenForScroll(),this.readSelectionRange()}onScrollChanged(e){this.view.inputState.runHandlers("scroll",e),this.intersecting&&this.view.measure()}onScroll(e){this.intersecting&&this.flush(!1),this.editContext&&this.view.requestMeasure(this.editContext.measureReq),this.onScrollChanged(e)}onResize(){this.resizeTimeout<0&&(this.resizeTimeout=setTimeout(()=>{this.resizeTimeout=-1,this.view.requestMeasure()},50))}onPrint(e){(e.type=="change"||!e.type)&&!e.matches||(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((n,r)=>n!=e[r]))){this.gapIntersection.disconnect();for(let n of e)this.gapIntersection.observe(n);this.gaps=e}}onSelectionChange(e){let n=this.selectionChanged;if(!this.readSelectionRange()||this.delayedAndroidKey)return;let{view:r}=this,s=this.selectionRange;if(r.state.facet(sr)?r.root.activeElement!=this.dom:!Ta(this.dom,s))return;let a=s.anchorNode&&r.docView.tile.nearest(s.anchorNode);if(a&&a.isWidget()&&a.widget.ignoreEvent(e)){n||(this.selectionChanged=!1);return}(Oe.ie&&Oe.ie_version<=11||Oe.android&&Oe.chrome)&&!r.state.selection.main.empty&&s.focusNode&&ja(s.focusNode,s.focusOffset,s.anchorNode,s.anchorOffset)?this.flushSoon():this.flush(!1)}readSelectionRange(){let{view:e}=this,n=Na(e.root);if(!n)return!1;let r=Oe.safari&&e.root.nodeType==11&&e.root.activeElement==this.dom&&vj(this.view,n)||n;if(!r||this.selectionRange.eq(r))return!1;let s=Ta(this.dom,r);return s&&!this.selectionChanged&&e.inputState.lastFocusTime>Date.now()-200&&e.inputState.lastTouchTime{let a=this.delayedAndroidKey;a&&(this.clearDelayedAndroidKey(),this.view.inputState.lastKeyCode=a.keyCode,this.view.inputState.lastKeyTime=Date.now(),!this.flush()&&a.force&&cl(this.dom,a.key,a.keyCode))};this.flushingAndroidKey=this.view.win.requestAnimationFrame(s)}(!this.delayedAndroidKey||e=="Enter")&&(this.delayedAndroidKey={key:e,keyCode:n,force:this.lastChange{this.delayedFlush=-1,this.flush()}))}forceFlush(){this.delayedFlush>=0&&(this.view.win.cancelAnimationFrame(this.delayedFlush),this.delayedFlush=-1),this.flush()}pendingRecords(){for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}processRecords(){let e=this.pendingRecords();e.length&&(this.queue=[]);let n=-1,r=-1,s=!1;for(let a of e){let c=this.readMutation(a);c&&(c.typeOver&&(s=!0),n==-1?{from:n,to:r}=c:(n=Math.min(c.from,n),r=Math.max(c.to,r)))}return{from:n,to:r,typeOver:s}}readChange(){let{from:e,to:n,typeOver:r}=this.processRecords(),s=this.selectionChanged&&Ta(this.dom,this.selectionRange);if(e<0&&!s)return null;e>-1&&(this.lastChange=Date.now()),this.view.inputState.lastFocusTime=0,this.selectionChanged=!1;let a=new BT(this.view,e,n,r);return this.view.docView.domChanged={newSel:a.newSel?a.newSel.main:null},a}flush(e=!0){if(this.delayedFlush>=0||this.delayedAndroidKey)return!1;e&&this.readSelectionRange();let n=this.readChange();if(!n)return this.view.requestMeasure(),!1;let r=this.view.state,s=Vb(this.view,n);return this.view.state==r&&(n.domChanged||n.newSel&&!mc(this.view.state.selection,n.newSel.main))&&this.view.update([]),s}readMutation(e){let n=this.view.docView.tile.nearest(e.target);if(!n||n.isWidget())return null;if(n.markDirty(e.type=="attributes"),e.type=="childList"){let r=gx(n,e.previousSibling||e.target.previousSibling,-1),s=gx(n,e.nextSibling||e.target.nextSibling,1);return{from:r?n.posAfter(r):n.posAtStart,to:s?n.posBefore(s):n.posAtEnd,typeOver:!1}}else return e.type=="characterData"?{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}:null}setWindow(e){e!=this.win&&(this.removeWindowListeners(this.win),this.win=e,this.addWindowListeners(this.win))}addWindowListeners(e){e.addEventListener("resize",this.onResize),this.printQuery?this.printQuery.addEventListener?this.printQuery.addEventListener("change",this.onPrint):this.printQuery.addListener(this.onPrint):e.addEventListener("beforeprint",this.onPrint),e.addEventListener("scroll",this.onScroll),e.document.addEventListener("selectionchange",this.onSelectionChange)}removeWindowListeners(e){e.removeEventListener("scroll",this.onScroll),e.removeEventListener("resize",this.onResize),this.printQuery?this.printQuery.removeEventListener?this.printQuery.removeEventListener("change",this.onPrint):this.printQuery.removeListener(this.onPrint):e.removeEventListener("beforeprint",this.onPrint),e.document.removeEventListener("selectionchange",this.onSelectionChange)}update(e){this.editContext&&(this.editContext.update(e),e.startState.facet(sr)!=e.state.facet(sr)&&(e.view.contentDOM.editContext=e.state.facet(sr)?this.editContext.editContext:null))}destroy(){var e,n,r;this.stop(),(e=this.intersection)===null||e===void 0||e.disconnect(),(n=this.gapIntersection)===null||n===void 0||n.disconnect(),(r=this.resizeScroll)===null||r===void 0||r.disconnect();for(let s of this.scrollTargets)s.removeEventListener("scroll",this.onScroll);this.removeWindowListeners(this.win),clearTimeout(this.parentCheck),clearTimeout(this.resizeTimeout),this.win.cancelAnimationFrame(this.delayedFlush),this.win.cancelAnimationFrame(this.flushingAndroidKey),this.editContext&&(this.view.contentDOM.editContext=null,this.editContext.destroy())}}function gx(t,e,n){for(;e;){let r=Ht.get(e);if(r&&r.parent==t)return r;let s=e.parentNode;e=s!=t.dom?s:n>0?e.nextSibling:e.previousSibling}return null}function yx(t,e){let n=e.startContainer,r=e.startOffset,s=e.endContainer,a=e.endOffset,c=t.docView.domAtPos(t.state.selection.main.anchor,1);return ja(c.node,c.offset,s,a)&&([n,r,s,a]=[s,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:s,focusOffset:a}}function vj(t,e){if(e.getComposedRanges){let s=e.getComposedRanges(t.root)[0];if(s)return yx(t,s)}let n=null;function r(s){s.preventDefault(),s.stopImmediatePropagation(),n=s.getTargetRanges()[0]}return t.contentDOM.addEventListener("beforeinput",r,!0),t.dom.ownerDocument.execCommand("indent"),t.contentDOM.removeEventListener("beforeinput",r,!0),n?yx(t,n):null}class wj{constructor(e){this.from=0,this.to=0,this.pendingContextChange=null,this.handlers=Object.create(null),this.composing=null,this.resetRange(e.state);let n=this.editContext=new window.EditContext({text:e.state.doc.sliceString(this.from,this.to),selectionStart:this.toContextPos(Math.max(this.from,Math.min(this.to,e.state.selection.main.anchor))),selectionEnd:this.toContextPos(e.state.selection.main.head)});this.handlers.textupdate=r=>{let s=e.state.selection.main,{anchor:a,head:c}=s,u=this.toEditorPos(r.updateRangeStart),f=this.toEditorPos(r.updateRangeEnd);e.inputState.composing>=0&&!this.composing&&(this.composing={contextBase:r.updateRangeStart,editorBase:u,drifted:!1});let h=f-u>r.text.length;u==this.from&&athis.to&&(f=a);let g=Fb(e.state.sliceDoc(u,f),r.text,(h?s.from:s.to)-u,h?"end":null);if(!g){let v=ke.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));mc(v,s)||e.dispatch({selection:v,userEvent:"select"});return}let b={from:g.from+u,to:g.toA+u,insert:mt.of(r.text.slice(g.from,g.toB).split(` +`))};if((Oe.mac||Oe.android)&&b.from==c-1&&/^\. ?$/.test(r.text)&&e.contentDOM.getAttribute("autocorrect")=="off"&&(b={from:u,to:f,insert:mt.of([r.text.replace("."," ")])}),this.pendingContextChange=b,!e.state.readOnly){let v=this.to-this.from+(b.to-b.from+b.insert.length);fh(e,b,ke.single(this.toEditorPos(r.selectionStart,v),this.toEditorPos(r.selectionEnd,v)))}this.pendingContextChange&&(this.revertPending(e.state),this.setSelection(e.state)),b.from=0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(n.text.slice(Math.max(0,r.updateRangeStart-1),Math.min(n.text.length,r.updateRangeStart+1)))&&this.handlers.compositionend(r)},this.handlers.characterboundsupdate=r=>{let s=[],a=null;for(let c=this.toEditorPos(r.rangeStart),u=this.toEditorPos(r.rangeEnd);c{let s=[];for(let a of r.getTextFormats()){let c=a.underlineStyle,u=a.underlineThickness;if(!/none/i.test(c)&&!/none/i.test(u)){let f=this.toEditorPos(a.rangeStart),h=this.toEditorPos(a.rangeEnd);if(f{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:r}=this.composing;this.composing=null,r&&this.reset(e.state)}};for(let r in this.handlers)n.addEventListener(r,this.handlers[r]);this.measureReq={read:r=>{let s=Na(r.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let n=0,r=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,c,u,f,h)=>{if(r)return;let g=h.length-(c-a);if(s&&c>=s.to)if(s.from==a&&s.to==c&&s.insert.eq(h)){s=this.pendingContextChange=null,n+=g,this.to+=g;return}else s=null,this.revertPending(e.state);if(a+=n,c+=n,c<=this.from)this.from+=g,this.to+=g;else if(athis.to||this.to-this.from+h.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(c),h.toString()),this.to+=g}n+=g}),s&&!r&&this.revertPending(e.state),!r}update(e){let n=this.pendingContextChange,r=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(r.from,r.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||n)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:n}=e.selection.main;this.from=Math.max(0,n-1e4),this.to=Math.min(e.doc.length,n+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let n=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(n.from),this.toContextPos(n.from+n.insert.length),e.doc.sliceString(n.from,n.to))}setSelection(e){let{main:n}=e.selection,r=this.toContextPos(Math.max(this.from,Math.min(this.to,n.anchor))),s=this.toContextPos(n.head);(this.editContext.selectionStart!=r||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(r,s)}rangeIsValid(e){let{head:n}=e.selection.main;return!(this.from>0&&n-this.from<500||this.to3e4)}toEditorPos(e,n=this.to-this.from){e=Math.min(e,n);let r=this.composing;return r&&r.drifted?r.editorBase+(e-r.contextBase):e+this.from}toContextPos(e){let n=this.composing;return n&&n.drifted?n.contextBase+(e-n.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Xe{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&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var n;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.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:r}=e;this.dispatchTransactions=e.dispatchTransactions||r&&(s=>s.forEach(a=>r(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||XN(e.parent)||document,this.viewState=new ux(this,e.state||St.create(e)),e.scrollTo&&e.scrollTo.is(oc)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(dl).map(s=>new nh(s));for(let s of this.plugins)s.update(this);this.observer=new xj(this),this.inputState=new zT(this),this.inputState.ensureHandlers(this.plugins),this.docView=new Bb(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((n=document.fonts)===null||n===void 0)&&n.ready&&document.fonts.ready.then(()=>{this.viewState.mustMeasureContent="refresh",this.requestMeasure()})}dispatch(...e){let n=e.length==1&&e[0]instanceof rn?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(n,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let n=!1,r=!1,s,a=this.state;for(let v of e){if(v.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=v.state}if(this.destroyed){this.viewState.state=a;return}let c=this.hasFocus,u=0,f=null;e.some(v=>v.annotation(nx))?(this.inputState.notifiedFocused=c,u=1):c!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=c,f=ix(a,c),f||(u=1));let h=this.observer.delayedAndroidKey,g=null;if(h?(this.observer.clearDelayedAndroidKey(),g=this.observer.readChange(),(g&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(g=null)):this.observer.clear(),a.facet(St.phrases)!=this.state.facet(St.phrases))return this.setState(a);s=uc.create(this,a,e),s.flags|=u;let b=this.viewState.scrollTarget;try{this.updateState=2;for(let v of e){if(b&&(b=b.map(v.changes)),v.scrollIntoView){let{main:w}=v.state.selection,{x:A,y:C}=this.state.facet(Xe.cursorScrollMargin);b=new ul(w.empty?w:ke.cursor(w.head,w.head>w.anchor?-1:1),"nearest","nearest",C,A)}for(let w of v.effects)w.is(oc)&&(b=w.value.clip(this.state))}this.viewState.update(s,b),this.bidiCache=Cc.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),n=this.docView.update(s),this.state.facet(Ma)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(n,e.some(v=>v.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(kc)!=s.state.facet(kc)&&(this.viewState.mustMeasureContent=!0),(n||r||b||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!s.empty)for(let v of this.state.facet(Zf))try{v(s)}catch(w){Fi(this.state,w,"update listener")}(f||g)&&Promise.resolve().then(()=>{f&&this.state==f.startState&&this.dispatch(f),g&&!Vb(this,g)&&h.force&&cl(this.contentDOM,h.key,h.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let n=this.hasFocus;try{for(let r of this.plugins)r.destroy(this);this.viewState=new ux(this,e),this.plugins=e.facet(dl).map(r=>new nh(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new Bb(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}n&&this.focus(),this.requestMeasure()}updatePlugins(e){let n=e.startState.facet(dl),r=e.state.facet(dl);if(n!=r){let s=[];for(let a of r){let c=n.indexOf(a);if(c<0)s.push(new nh(a));else{let u=this.plugins[c];u.mustUpdate=e,s.push(u)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let n=null,r=this.viewState.scrollParent,s=this.viewState.getScrollOffset(),{scrollAnchorPos:a,scrollAnchorHeight:c,scaleY:u}=this.viewState;Math.abs(s-this.viewState.scrollOffset)>1&&(c=-1),this.viewState.scrollAnchorHeight=-1;try{for(let f=0;;f++){if(c<0){if(ub(r||this.win))a=-1,c=this.viewState.heightMap.height/this.viewState.scaleY;else{let A=this.viewState.scrollAnchorAt(s);a=A.from,c=A.top}u=this.viewState.scaleY}this.updateState=1;let h=this.viewState.measure();if(!h&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(f>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let g=[];h&4||([this.measureRequests,g]=[g,this.measureRequests]);let b=g.map(A=>{try{return A.read(this)}catch(C){return Fi(this.state,C),bx}}),v=uc.create(this,this.state,[]),w=!1;v.flags|=h,n?n.flags|=h:n=v,this.updateState=2,v.empty||(this.updatePlugins(v),this.inputState.update(v),this.updateAttrs(),w=this.docView.update(v),w&&this.docViewUpdate());for(let A=0;A1||C<-1)&&!(Oe.ios&&this.inputState.lastIOSMomentumScroll>Date.now()-100)&&(r==this.scrollDOM||this.hasFocus||Math.max(this.inputState.lastWheelEvent,this.inputState.lastTouchTime)>Date.now()-100)){s=s+C,r?a<0?r.scrollTop=r.scrollHeight:r.scrollTop+=C:this.win.scrollBy(0,C),c=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let f of this.state.facet(Zf))f(n)}get themeClasses(){return bh+" "+(this.state.facet(yh)?px:hx)+" "+this.state.facet(kc)}updateAttrs(){let e=xx(this,jb,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(sr)?"true":"false",class:"cm-content",style:`${Oe.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),xx(this,ih,n);let r=this.observer.ignore(()=>{let s=tb(this.contentDOM,this.contentAttrs,n),a=tb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=n,r}showAnnouncements(e){let n=!0;for(let r of e)for(let s of r.effects)if(s.is(Xe.announce)){n&&(this.announceDOM.textContent=""),n=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Ma);let e=this.state.facet(Xe.cspNonce);al.mount(this.root,this.styleModules.concat(yj).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let n=0;nr.plugin==e)||null),n&&n.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}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,n,r){return uh(this,e,Ib(this,e,n,r))}moveByGroup(e,n){return uh(this,e,Ib(this,e,n,r=>MT(this,e.head,r)))}visualLineSide(e,n){let r=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=r[n?r.length-1:0];return ke.cursor(a.side(n,s)+e.from,a.forward(!n,s)?1:-1)}moveToLineBoundary(e,n,r=!0){return OT(this,e,n,r)}moveVertically(e,n,r){return uh(this,e,RT(this,e,n,r))}domAtPos(e,n=1){return this.docView.domAtPos(e,n)}posAtDOM(e,n=0){return this.docView.posFromDOM(e,n)}posAtCoords(e,n=!0){this.readMeasured();let r=dh(this,e,n);return r&&r.pos}posAndSideAtCoords(e,n=!0){return this.readMeasured(),dh(this,e,n)}coordsAtPos(e,n=1){this.readMeasured();let r=this.state.doc.lineAt(e),s=this.bidiSpans(r),a=s[Vi.find(s,e-r.from,-1,n)];return this.docView.coordsAt(e,n,a.dir==Bt.RTL)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}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(kb)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Sj)return gb(e.length);let n=this.textDirectionAt(e.from),r;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==n&&(a.fresh||mb(a.isolates,r=Mb(this,e))))return a.order;r||(r=Mb(this,e));let s=iT(e.text,n,r);return this.bidiCache.push(new Cc(e.from,e.to,n,r,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Oe.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{ob(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,n={}){var r,s,a,c;return oc.of(new ul(typeof e=="number"?ke.cursor(e):e,(r=n.y)!==null&&r!==void 0?r:"nearest",(s=n.x)!==null&&s!==void 0?s:"nearest",(a=n.yMargin)!==null&&a!==void 0?a:5,(c=n.xMargin)!==null&&c!==void 0?c:5))}scrollSnapshot(){let{scrollTop:e,scrollLeft:n}=this.scrollDOM,r=this.viewState.scrollAnchorAt(e);return oc.of(new ul(ke.cursor(r.from),"start","start",r.top-e,n,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return lr.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return lr.define(()=>({}),{eventObservers:e})}static theme(e,n){let r=al.newName(),s=[kc.of(r),Ma.of(xh(`.${r}`,e))];return n&&n.dark&&s.push(yh.of(!0)),s}static baseTheme(e){return Jo.lowest(Ma.of(xh("."+bh,e,mx)))}static findFromDOM(e){var n;let r=e.querySelector(".cm-content"),s=r&&Ht.get(r)||Ht.get(e);return((n=s?.root)===null||n===void 0?void 0:n.view)||null}}Xe.styleModule=Ma,Xe.inputHandler=Sb,Xe.clipboardInputFilter=eh,Xe.clipboardOutputFilter=th,Xe.scrollHandler=Nb,Xe.focusChangeEffect=Ab,Xe.perLineTextDirection=kb,Xe.exceptionSink=wb,Xe.updateListener=Zf,Xe.editable=sr,Xe.mouseSelectionStyle=vb,Xe.dragMovesSelection=xb,Xe.clickAddsSelectionRange=bb,Xe.decorations=cc,Xe.blockWrappers=Eb,Xe.outerDecorations=rh,Xe.atomicRanges=Oa,Xe.bidiIsolatedRanges=Ob,Xe.cursorScrollMargin=Ue.define({combine:t=>{let e=5,n=5;for(let r of t)typeof r=="number"?e=n=r:{x:e,y:n}=r;return{x:e,y:n}}}),Xe.scrollMargins=Rb,Xe.darkTheme=yh,Xe.cspNonce=Ue.define({combine:t=>t.length?t[0]:""}),Xe.contentAttributes=ih,Xe.editorAttributes=jb,Xe.lineWrapping=Xe.contentAttributes.of({class:"cm-lineWrapping"}),Xe.announce=Ft.define();const Sj=4096,bx={};class Cc{constructor(e,n,r,s,a,c){this.from=e,this.to=n,this.dir=r,this.isolates=s,this.fresh=a,this.order=c}static update(e,n){if(n.empty&&!e.some(a=>a.fresh))return e;let r=[],s=e.length?e[e.length-1].dir:Bt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=r[s],c=typeof a=="function"?a(t):a;c&&Yf(c,n)}return n}const Aj=Oe.mac?"mac":Oe.windows?"win":Oe.linux?"linux":"key";function kj(t,e){const n=t.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let s,a,c,u;for(let f=0;fr.concat(s),[]))),n}let Hr=null;const Tj=4e3;function jj(t,e=Aj){let n=Object.create(null),r=Object.create(null),s=(c,u)=>{let f=r[c];if(f==null)r[c]=u;else if(f!=u)throw new Error("Key binding "+c+" is used both as a regular binding and as a multi-stroke prefix")},a=(c,u,f,h,g)=>{var b,v;let w=n[c]||(n[c]=Object.create(null)),A=u.split(/ (?!$)/).map(D=>kj(D,e));for(let D=1;D{let R=Hr={view:j,prefix:O,scope:c};return setTimeout(()=>{Hr==R&&(Hr=null)},Tj),!0}]})}let C=A.join(" ");s(C,!1);let E=w[C]||(w[C]={preventDefault:!1,stopPropagation:!1,run:((v=(b=w._any)===null||b===void 0?void 0:b.run)===null||v===void 0?void 0:v.slice())||[]});f&&E.run.push(f),h&&(E.preventDefault=!0),g&&(E.stopPropagation=!0)};for(let c of t){let u=c.scope?c.scope.split(" "):["editor"];if(c.any)for(let h of u){let g=n[h]||(n[h]=Object.create(null));g._any||(g._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:b}=c;for(let v in g)g[v].run.push(w=>b(w,wh))}let f=c[e]||c.key;if(f)for(let h of u)a(h,f,c.run,c.preventDefault,c.stopPropagation),c.shift&&a(h,"Shift-"+f,c.shift,c.preventDefault,c.stopPropagation)}return n}let wh=null;function Ej(t,e,n,r){wh=e;let s=UN(e),a=kN(s,0),c=CN(a)==s.length&&s!=" ",u="",f=!1,h=!1,g=!1;Hr&&Hr.view==n&&Hr.scope==r&&(u=Hr.prefix+" ",Kb.indexOf(e.keyCode)<0&&(h=!0,Hr=null));let b=new Set,v=E=>{if(E){for(let D of E.run)if(!b.has(D)&&(b.add(D),D(n)))return E.stopPropagation&&(g=!0),!0;E.preventDefault&&(E.stopPropagation&&(g=!0),h=!0)}return!1},w=t[r],A,C;return w&&(v(w[u+Nc(s,e,!c)])?f=!0:c&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Oe.windows&&e.ctrlKey&&e.altKey)&&!(Oe.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(A=$r[e.keyCode])&&A!=s?(v(w[u+Nc(A,e,!0)])||e.shiftKey&&(C=Sa[e.keyCode])!=s&&C!=A&&v(w[u+Nc(C,e,!1)]))&&(f=!0):c&&e.shiftKey&&v(w[u+Nc(s,e,!0)])&&(f=!0),!f&&v(w._any)&&(f=!0)),h&&(f=!0),f&&g&&e.stopPropagation(),wh=null,f}class Ds{constructor(e,n,r,s,a){this.className=e,this.left=n,this.top=r,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,n){return n.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(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}static forRange(e,n,r){if(r.empty){let s=e.coordsAtPos(r.head,r.assoc||1);if(!s)return[];let a=Sx(e);return[new Ds(n,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return Oj(e,n,r)}}function Sx(t){let e=t.scrollDOM.getBoundingClientRect();return{left:(t.textDirection==Bt.LTR?e.left:e.right-t.scrollDOM.clientWidth*t.scaleX)-t.scrollDOM.scrollLeft*t.scaleX,top:e.top-t.scrollDOM.scrollTop*t.scaleY}}function Ax(t,e,n,r){let s=t.coordsAtPos(e,n*2);if(!s)return r;let a=t.dom.getBoundingClientRect(),c=(s.top+s.bottom)/2,u=t.posAtCoords({x:a.left+1,y:c}),f=t.posAtCoords({x:a.right-1,y:c});return u==null||f==null?r:{from:Math.max(r.from,Math.min(u,f)),to:Math.min(r.to,Math.max(u,f))}}function Oj(t,e,n){if(n.to<=t.viewport.from||n.from>=t.viewport.to)return[];let r=Math.max(n.from,t.viewport.from),s=Math.min(n.to,t.viewport.to),a=t.textDirection==Bt.LTR,c=t.contentDOM,u=c.getBoundingClientRect(),f=Sx(t),h=c.querySelector(".cm-line"),g=h&&window.getComputedStyle(h),b=u.left+(g?parseInt(g.paddingLeft)+Math.min(0,parseInt(g.textIndent)):0),v=u.right-(g?parseInt(g.paddingRight):0),w=ch(t,r,1),A=ch(t,s,-1),C=w.type==fn.Text?w:null,E=A.type==fn.Text?A:null;if(C&&(t.lineWrapping||w.widgetLineBreaks)&&(C=Ax(t,r,1,C)),E&&(t.lineWrapping||A.widgetLineBreaks)&&(E=Ax(t,s,-1,E)),C&&E&&C.from==E.from&&C.to==E.to)return O(j(n.from,n.to,C));{let _=C?j(n.from,null,C):R(w,!1),L=E?j(null,n.to,E):R(A,!0),M=[];return(C||w).to<(E||A).from-(C&&E?1:0)||w.widgetLineBreaks>1&&_.bottom+t.defaultLineHeight/2ee&&ce.from=q)break;Se>ge&&K(Math.max(he,ge),_==null&&he<=ee,Math.min(Se,q),L==null&&Se>=be,oe.dir)}if(ge=J.to+1,ge>=q)break}return B.length==0&&K(ee,_==null,be,L==null,t.textDirection),{top:G,bottom:Y,horizontal:B}}function R(_,L){let M=u.top+(L?_.top:_.bottom);return{top:M,bottom:M,horizontal:[]}}}function Mj(t,e){return t.constructor==e.constructor&&t.eq(e)}class Rj{constructor(e,n){this.view=e,this.layer=n,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),n.above&&this.dom.classList.add("cm-layer-above"),n.class&&this.dom.classList.add(n.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),n.mount&&n.mount(this.dom,e)}update(e){e.startState.facet(Tc)!=e.state.facet(Tc)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let n=0,r=e.facet(Tc);for(;n!Mj(n,this.drawn[r]))){let n=this.dom.firstChild,r=0;for(let s of e)s.update&&n&&s.constructor&&this.drawn[r].constructor&&s.update(n,this.drawn[r])?(n=n.nextSibling,r++):this.dom.insertBefore(s.draw(),n);for(;n;){let s=n.nextSibling;n.remove(),n=s}this.drawn=e,Oe.webkit&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const Tc=Ue.define();function kx(t){return[lr.define(e=>new Rj(e,t)),Tc.of(t)]}const gl=Ue.define({combine(t){return Mf(t,{cursorBlinkRate:1200,drawRangeCursor:!0,iosSelectionHandles:!0},{cursorBlinkRate:(e,n)=>Math.min(e,n),drawRangeCursor:(e,n)=>e||n})}});function Dj(t={}){return[gl.of(t),_j,Lj,Bj,Cb.of(!0)]}function Cx(t){return t.startState.facet(gl)!=t.state.facet(gl)}const _j=kx({above:!0,markers(t){let{state:e}=t,n=e.facet(gl),r=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||n.drawRangeCursor&&!(a&&Oe.ios&&n.iosSelectionHandles)){let c=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",u=s.empty?s:ke.cursor(s.head,s.assoc);for(let f of Ds.forRange(t,c,u))r.push(f)}}return r},update(t,e){t.transactions.some(r=>r.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let n=Cx(t);return n&&Nx(t.state,e),t.docChanged||t.selectionSet||n},mount(t,e){Nx(e.state,t)},class:"cm-cursorLayer"});function Nx(t,e){e.style.animationDuration=t.facet(gl).cursorBlinkRate+"ms"}const Lj=kx({above:!1,markers(t){let e=[],{main:n,ranges:r}=t.state.selection;for(let s of r)if(!s.empty)for(let a of Ds.forRange(t,"cm-selectionBackground",s))e.push(a);if(Oe.ios&&!n.empty&&t.state.facet(gl).iosSelectionHandles){for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-start",ke.cursor(n.from,1)))e.push(s);for(let s of Ds.forRange(t,"cm-selectionHandle cm-selectionHandle-end",ke.cursor(n.to,1)))e.push(s)}return e},update(t,e){return t.docChanged||t.selectionSet||t.viewportChanged||Cx(t)},class:"cm-selectionLayer"}),qj=Oe.gecko&&Oe.gecko_version==153?"#ffffff01":"transparent",Bj=Jo.highest(Xe.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:`${qj} !important`},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}}));function Tx(){return Ij}const $j=ln.line({class:"cm-activeLine"}),Ij=lr.fromClass(class{constructor(t){this.decorations=this.getDeco(t)}update(t){(t.docChanged||t.selectionSet)&&(this.decorations=this.getDeco(t.view))}getDeco(t){let e=-1,n=[];for(let r of t.state.selection.ranges){let s=t.lineBlockAt(r.head);s.from>e&&(n.push($j.range(s.from)),e=s.from)}return ln.set(n)}},{decorations:t=>t.decorations});class zr extends Ts{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}zr.prototype.elementClass="",zr.prototype.toDOM=void 0,zr.prototype.mapMode=Wn.TrackBefore,zr.prototype.startSide=zr.prototype.endSide=-1,zr.prototype.point=!0;const jc=Ue.define(),Hj=Ue.define(),Ec=Ue.define(),jx=Ue.define({combine:t=>t.some(e=>e)});function zj(t){return[Uj]}const Uj=lr.fromClass(class{constructor(t){this.view=t,this.domAfter=null,this.prevViewport=t.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=t.state.facet(Ec).map(e=>new Ox(t,e)),this.fixed=!t.state.facet(jx);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),t.scrollDOM.insertBefore(this.dom,t.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(t){if(this.updateGutters(t)){let e=this.prevViewport,n=t.view.viewport,r=Math.min(e.to,n.to)-Math.max(e.from,n.from);this.syncGutters(r<(n.to-n.from)*.8)}if(t.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(jx)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=t.view.viewport}syncGutters(t){let e=this.dom.nextSibling;t&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let n=pt.iter(this.view.state.facet(jc),this.view.viewport.from),r=[],s=this.gutters.map(a=>new Vj(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let c=!0;for(let u of a.type)if(u.type==fn.Text&&c){Sh(n,r,u.from);for(let f of s)f.line(this.view,u,r);c=!1}else if(u.widget)for(let f of s)f.widget(this.view,u)}else if(a.type==fn.Text){Sh(n,r,a.from);for(let c of s)c.line(this.view,a,r)}else if(a.widget)for(let c of s)c.widget(this.view,a);for(let a of s)a.finish();t&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(t){let e=t.startState.facet(Ec),n=t.state.facet(Ec),r=t.docChanged||t.heightChanged||t.viewportChanged||!pt.eq(t.startState.facet(jc),t.state.facet(jc),t.view.viewport.from,t.view.viewport.to);if(e==n)for(let s of this.gutters)s.update(t)&&(r=!0);else{r=!0;let s=[];for(let a of n){let c=e.indexOf(a);c<0?s.push(new Ox(this.view,a)):(this.gutters[c].update(t),s.push(this.gutters[c]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return r}destroy(){for(let t of this.gutters)t.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:t=>Xe.scrollMargins.of(e=>{let n=e.plugin(t);if(!n||n.gutters.length==0||!n.fixed)return null;let r=n.dom.offsetWidth*e.scaleX,s=n.domAfter?n.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Bt.LTR?{left:r,right:s}:{right:r,left:s}})});function Ex(t){return Array.isArray(t)?t:[t]}function Sh(t,e,n){for(;t.value&&t.from<=n;)t.from==n&&e.push(t.value),t.next()}class Vj{constructor(e,n,r){this.gutter=e,this.height=r,this.i=0,this.cursor=pt.iter(e.markers,n.from)}addElement(e,n,r){let{gutter:s}=this,a=(n.top-this.height)/e.scaleY,c=n.height/e.scaleY;if(this.i==s.elements.length){let u=new Mx(e,c,a,r);s.elements.push(u),s.dom.appendChild(u.dom)}else s.elements[this.i].update(e,c,a,r);this.height=n.bottom,this.i++}line(e,n,r){let s=[];Sh(this.cursor,s,n.from),r.length&&(s=s.concat(r));let a=this.gutter.config.lineMarker(e,n,s);a&&s.unshift(a);let c=this.gutter;s.length==0&&!c.config.renderEmptyElements||this.addElement(e,n,s)}widget(e,n){let r=this.gutter.config.widgetMarker(e,n.widget,n),s=r?[r]:null;for(let a of e.state.facet(Hj)){let c=a(e,n.widget,n);c&&(s||(s=[])).push(c)}s&&this.addElement(e,n,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let n=e.elements.pop();e.dom.removeChild(n.dom),n.destroy()}}}class Ox{constructor(e,n){this.view=e,this.config=n,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let r in n.domEventHandlers)this.dom.addEventListener(r,s=>{let a=s.target,c;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let f=a.getBoundingClientRect();c=(f.top+f.bottom)/2}else c=s.clientY;let u=e.lineBlockAtHeight(c-e.documentTop);n.domEventHandlers[r](e,u,s)&&s.preventDefault()});this.markers=Ex(n.markers(e)),n.initialSpacer&&(this.spacer=new Mx(e,0,0,[n.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let n=this.markers;if(this.markers=Ex(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let r=e.view.viewport;return!pt.eq(this.markers,n,r.from,r.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class Mx{constructor(e,n,r,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,n,r,s)}update(e,n,r,s){this.height!=n&&(this.height=n,this.dom.style.height=n+"px"),this.above!=r&&(this.dom.style.marginTop=(this.above=r)?r+"px":""),Fj(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,n){let r="cm-gutterElement",s=this.dom.firstChild;for(let a=0,c=0;;){let u=c,f=aa(u,f,h)||c(u,f,h):c}return r}})}});class Ah extends zr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function kh(t,e){return t.state.facet(yl).formatNumber(e,t.state)}const Kj=Ec.compute([yl],t=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Pj)},lineMarker(e,n,r){return r.some(s=>s.toDOM)?null:new Ah(kh(e,e.state.doc.lineAt(n.from).number))},widgetMarker:(e,n,r)=>{for(let s of e.state.facet(Yj)){let a=s(e,n,r);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(yl)!=e.state.facet(yl),initialSpacer(e){return new Ah(kh(e,Dx(e.state.doc.lines)))},updateSpacer(e,n){let r=kh(n.view,Dx(n.view.state.doc.lines));return r==e.number?e:new Ah(r)},domEventHandlers:t.facet(yl).domEventHandlers,side:"before"}));function Rx(t={}){return[yl.of(t),zj(),Kj]}function Dx(t){let e=9;for(;e{let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.head).from;s>n&&(n=s,e.push(Gj.range(s)))}return pt.of(e)});function _x(){return Xj}const Jj=1024;let Qj=0;class Ch{constructor(e,n){this.from=e,this.to=n}}class gt{constructor(e={}){this.id=Qj++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=mi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}gt.closedBy=new gt({deserialize:t=>t.split(" ")}),gt.openedBy=new gt({deserialize:t=>t.split(" ")}),gt.group=new gt({deserialize:t=>t.split(" ")}),gt.isolate=new gt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),gt.contextHash=new gt({perNode:!0}),gt.lookAhead=new gt({perNode:!0}),gt.mounted=new gt({perNode:!0});class _a{constructor(e,n,r,s=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=s}static get(e){return e&&e.props&&e.props[gt.mounted.id]}}const Wj=Object.create(null);class mi{constructor(e,n,r,s=0){this.name=e,this.props=n,this.id=r,this.flags=s}static define(e){let n=e.props&&e.props.length?Object.create(null):Wj,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new mi(e.name||"",n,e.id,r);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(gt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let s of r.split(" "))n[s]=e[r];return r=>{for(let s=r.prop(gt.group),a=-1;a<(s?s.length:0);a++){let c=n[a<0?r.name:s[a]];if(c)return c}}}}mi.none=new mi("",Object.create(null),0,8);const Oc=new WeakMap,Lx=new WeakMap;var Pt;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Pt||(Pt={}));class pn{constructor(e,n,r,s,a){if(this.type=e,this.children=n,this.positions=r,this.length=s,this.props=null,a&&a.length){this.props=Object.create(null);for(let[c,u]of a)this.props[typeof c=="number"?c:c.id]=u}}toString(){let e=_a.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let s=r.toString();s&&(n&&(n+=","),n+=s)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new jh(this.topNode,e)}cursorAt(e,n=0,r=0){let s=Oc.get(this)||this.topNode,a=new jh(s);return a.moveTo(e,n),Oc.set(this,a._tree),a}get topNode(){return new gi(this,0,0,null)}resolve(e,n=0){let r=La(Oc.get(this)||this.topNode,e,n,!1);return Oc.set(this,r),r}resolveInner(e,n=0){let r=La(Lx.get(this)||this.topNode,e,n,!0);return Lx.set(this,r),r}resolveStack(e,n=0){return tE(this,e,n)}iterate(e){let{enter:n,leave:r,from:s=0,to:a=this.length}=e,c=e.mode||0,u=(c&Pt.IncludeAnonymous)>0;for(let f=this.cursor(c|Pt.IncludeAnonymous);;){let h=!1;if(f.from<=a&&f.to>=s&&(!u&&f.type.isAnonymous||n(f)!==!1)){if(f.firstChild())continue;h=!0}for(;h&&r&&(u||!f.type.isAnonymous)&&r(f),!f.nextSibling();){if(!f.parent())return;h=!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 n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Oh(mi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,s)=>new pn(this.type,n,r,s,this.propValues),e.makeTree||((n,r,s)=>new pn(mi.none,n,r,s)))}static build(e){return nE(e)}}pn.empty=new pn(mi.none,[],[],0);class Nh{constructor(e,n){this.buffer=e,this.index=n}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 Nh(this.buffer,this.index)}}class Ur{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return mi.none}toString(){let e=[];for(let n=0;n0));f=c[f+3]);return u}slice(e,n,r){let s=this.buffer,a=new Uint16Array(n-e),c=0;for(let u=e,f=0;u=e&&ne;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function La(t,e,n,r){for(var s;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to0?u.length:-1;e!=h;e+=n){let g=u[e],b=f[e]+c.from,v;if(!(!(a&Pt.EnterBracketed&&g instanceof pn&&(v=_a.get(g))&&!v.overlay&&v.bracketed&&r>=b&&r<=b+g.length)&&!qx(s,r,b,b+g.length))){if(g instanceof Ur){if(a&Pt.ExcludeBuffers)continue;let w=g.findChild(0,g.buffer.length,n,r-b,s);if(w>-1)return new Vr(new Zj(c,g,e,b),null,w)}else if(a&Pt.IncludeAnonymous||!g.type.isAnonymous||Eh(g)){let w;if(!(a&Pt.IgnoreMounts)&&(w=_a.get(g))&&!w.overlay)return new gi(w.tree,b,e,c);let A=new gi(g,b,e,c);return a&Pt.IncludeAnonymous||!A.type.isAnonymous?A:A.nextChild(n<0?g.children.length-1:0,n,r,s,a)}}}if(a&Pt.IncludeAnonymous||!c.type.isAnonymous||(c.index>=0?e=c.index+n:e=n<0?-1:c._parent._tree.children.length,c=c._parent,!c))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)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let s;if(!(r&Pt.IgnoreOverlays)&&(s=_a.get(this._tree))&&s.overlay){let a=e-this.from,c=r&Pt.EnterBracketed&&s.bracketed;for(let{from:u,to:f}of s.overlay)if((n>0||c?u<=a:u=a:f>a))return new gi(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}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}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function $x(t,e,n,r){let s=t.cursor(),a=[];if(!s.firstChild())return a;if(n!=null){for(let c=!1;!c;)if(c=s.type.is(n),!s.nextSibling())return a}for(;;){if(r!=null&&s.type.is(r))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return r==null?a:[]}}function Th(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class Zj{constructor(e,n,r,s){this.parent=e,this.buffer=n,this.index=r,this.start=s}}class Vr extends Bx{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]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.context.start,r);return a<0?null:new Vr(this.context,this,a)}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)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Pt.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return a<0?null:new Vr(this.context,this,a)}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,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new Vr(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vr(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,s=this.index+4,a=r.buffer[this.index+3];if(a>s){let c=r.buffer[this.index+1];e.push(r.slice(s,a,c)),n.push(0)}return new pn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function Ix(t){if(!t.length)return null;let e=0,n=t[0];for(let a=1;an.from||c.to=e){let u=new gi(c.tree,c.overlay[0].from+a.from,-1,a);(s||(s=[r])).push(La(u,e,n,!1))}}return s?Ix(s):r}class jh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Pt.EnterBracketed,e instanceof gi)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:s}=this.buffer;return this.type=n||s.set.types[s.buffer[e]],this.from=r+s.buffer[e+1],this.to=r+s.buffer[e+2],!0}yield(e){return e?e instanceof gi?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}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,n,r=this.mode){return this.buffer?r&Pt.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Pt.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Pt.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)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let s=r<0?0:this.stack[r]+4;if(this.index!=s)return this.yieldBuf(n.findChild(s,this.index,-1,0,4))}else{let s=n.buffer[this.index+3];if(s<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(s)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=n+e,c=e<0?-1:r._tree.children.length;a!=c;a+=e){let u=r._tree.children[a];if(this.mode&Pt.IncludeAnonymous||u instanceof Ur||!u.type.isAnonymous||Eh(u))return!1}return!0}move(e,n){if(n&&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,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to=0;){for(let c=e;c;c=c._parent)if(c.index==s){if(s==this.index)return c;n=c,r=a+1;break e}s=this.stack[--a]}for(let s=r;s=0;a--){if(a<0)return Th(this._tree,e,s);let c=r[n.buffer[this.stack[a]]];if(!c.isAnonymous){if(e[s]&&e[s]!=c.name)return!1;s--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof Ur||!e.type.isAnonymous||Eh(e))}function nE(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:s=Jj,reused:a=[],minRepeatType:c=r.types.length}=t,u=Array.isArray(n)?new Nh(n,n.length):n,f=r.types,h=0,g=0;function b(_,L,M,G,Y,B){let{id:K,start:ee,end:be,size:ce}=u,ge=g,q=h;if(ce<0)if(u.next(),ce==-1){let T=a[K];M.push(T),G.push(ee-_);return}else if(ce==-3){h=K;return}else if(ce==-4){g=K;return}else throw new RangeError(`Unrecognized record size: ${ce}`);let J=f[K],oe,he,Se=ee-_;if(be-ee<=s&&(he=E(u.pos-L,Y))){let T=new Uint16Array(he.size-he.skip),z=u.pos-he.size,me=T.length;for(;u.pos>z;)me=D(he.start,T,me);oe=new Ur(T,be-he.start,r),Se=he.start-_}else{let T=u.pos-ce;u.next();let z=[],me=[],ne=K>=c?K:-1,Ce=0,Re=be;for(;u.pos>T;)ne>=0&&u.id==ne&&u.size>=0?(u.end<=Re-s&&(A(z,me,ee,Ce,u.end,Re,ne,ge,q),Ce=z.length,Re=u.end),u.next()):B>2500?v(ee,T,z,me):b(ee,T,z,me,ne,B+1);if(ne>=0&&Ce>0&&Ce-1&&Ce>0){let qe=w(J,q);oe=Oh(J,z,me,0,z.length,0,be-ee,qe,qe)}else oe=C(J,z,me,be-ee,ge-be,q)}M.push(oe),G.push(Se)}function v(_,L,M,G){let Y=[],B=0,K=-1;for(;u.pos>L;){let{id:ee,start:be,end:ce,size:ge}=u;if(ge>4)u.next();else{if(K>-1&&be=0;ce-=3)ee[ge++]=Y[ce],ee[ge++]=Y[ce+1]-be,ee[ge++]=Y[ce+2]-be,ee[ge++]=ge;M.push(new Ur(ee,Y[2]-be,r)),G.push(be-_)}}function w(_,L){return(M,G,Y)=>{let B=0,K=M.length-1,ee,be;if(K>=0&&(ee=M[K])instanceof pn){if(!K&&ee.type==_&&ee.length==Y)return ee;(be=ee.prop(gt.lookAhead))&&(B=G[K]+ee.length+be)}return C(_,M,G,Y,B,L)}}function A(_,L,M,G,Y,B,K,ee,be){let ce=[],ge=[];for(;_.length>G;)ce.push(_.pop()),ge.push(L.pop()+M-Y);_.push(C(r.types[K],ce,ge,B-Y,ee-B,be)),L.push(Y-M)}function C(_,L,M,G,Y,B,K){if(B){let ee=[gt.contextHash,B];K=K?[ee].concat(K):[ee]}if(Y>25){let ee=[gt.lookAhead,Y];K=K?[ee].concat(K):[ee]}return new pn(_,L,M,G,K)}function E(_,L){let M=u.fork(),G=0,Y=0,B=0,K=M.end-s,ee={size:0,start:0,skip:0};e:for(let be=M.pos-_;M.pos>be;){let ce=M.size;if(M.id==L&&ce>=0){ee.size=G,ee.start=Y,ee.skip=B,B+=4,G+=4,M.next();continue}let ge=M.pos-ce;if(ce<0||ge=c?4:0,J=M.start;for(M.next();M.pos>ge;){if(M.size<0)if(M.size==-3||M.size==-4)q+=4;else break e;else M.id>=c&&(q+=4);M.next()}Y=J,G+=ce,B+=q}return(L<0||G==_)&&(ee.size=G,ee.start=Y,ee.skip=B),ee.size>4?ee:void 0}function D(_,L,M){let{id:G,start:Y,end:B,size:K}=u;if(u.next(),K>=0&&G4){let be=u.pos-(K-4);for(;u.pos>be;)M=D(_,L,M)}L[--M]=ee,L[--M]=B-_,L[--M]=Y-_,L[--M]=G}else K==-3?h=G:K==-4&&(g=G);return M}let O=[],j=[];for(;u.pos>0;)b(t.start||0,t.bufferStart||0,O,j,-1,0);let R=(e=t.length)!==null&&e!==void 0?e:O.length?j[0]+O[0].length:0;return new pn(f[t.topID],O.reverse(),j.reverse(),R)}const Hx=new WeakMap;function Mc(t,e){if(!t.isAnonymous||e instanceof Ur||e.type!=t)return 1;let n=Hx.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof pn)){n=1;break}n+=Mc(t,r)}Hx.set(e,n)}return n}function Oh(t,e,n,r,s,a,c,u,f){let h=0;for(let A=r;A=g)break;L+=M}if(j==R+1){if(L>g){let M=A[R];w(M.children,M.positions,0,M.children.length,C[R]+O);continue}b.push(A[R])}else{let M=C[j-1]+A[j-1].length-_;b.push(Oh(t,A,C,R,j,_,M,null,f))}v.push(_+O-a)}}return w(e,n,r,s,0),(u||f)(b,v,c)}class _s{constructor(e,n,r,s,a=!1,c=!1){this.from=e,this.to=n,this.tree=r,this.offset=s,this.open=(a?1:0)|(c?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let s=[new _s(0,e.length,e,0,!1,r)];for(let a of n)a.to>e.length&&s.push(a);return s}static applyChanges(e,n,r=128){if(!n.length)return e;let s=[],a=1,c=e.length?e[0]:null;for(let u=0,f=0,h=0;;u++){let g=u=r)for(;c&&c.from=v.from||b<=v.to||h){let w=Math.max(v.from,f)-h,A=Math.min(v.to,b)-h;v=w>=A?null:new _s(w,A,v.tree,v.offset+h,u>0,!!g)}if(v&&s.push(v),c.to>b)break;c=anew Ch(s.from,s.to)):[new Ch(0,0)]:[new Ch(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let s=this.startParse(e,n,r);for(;;){let a=s.advance();if(a)return a}}}class rE{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new gt({perNode:!0});let sE=0;class yi{constructor(e,n,r,s){this.name=e,this.set=n,this.base=r,this.modified=s,this.id=sE++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof yi&&(n=e),n?.base)throw new Error("Can not derive from a modified tag");let s=new yi(r,[],null,[]);if(s.set.push(s),n)for(let a of n.set)s.set.push(a);return s}static defineModifier(e){let n=new Rc(e);return r=>r.modified.indexOf(n)>-1?r:Rc.get(r.base||r,r.modified.concat(n).sort((s,a)=>s.id-a.id))}}let lE=0;class Rc{constructor(e){this.name=e,this.instances=[],this.id=lE++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(u=>u.base==e&&aE(n,u.modified));if(r)return r;let s=[],a=new yi(e.name,s,e,n);for(let u of n)u.instances.push(a);let c=oE(n);for(let u of e.set)if(!u.modified.length)for(let f of c)s.push(Rc.get(u,f));return a}}function aE(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function oE(t){let e=[[]];for(let n=0;nr.length-n.length)}function cE(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let s of n.split(" "))if(s){let a=[],c=2,u=s;for(let b=0;;){if(u=="..."&&b>0&&b+3==s.length){c=1;break}let v=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(u);if(!v)throw new RangeError("Invalid path: "+s);if(a.push(v[0]=="*"?"":v[0][0]=='"'?JSON.parse(v[0]):v[0]),b+=v[0].length,b==s.length)break;let w=s[b++];if(b==s.length&&w=="!"){c=0;break}if(w!="/")throw new RangeError("Invalid path: "+s);u=s.slice(b)}let f=a.length-1,h=a[f];if(!h)throw new RangeError("Invalid path: "+s);let g=new Dc(r,c,f>0?a.slice(0,f):null);e[h]=g.sort(e[h])}}return uE.add(e)}const uE=new gt({combine(t,e){let n,r,s;for(;t||e;){if(!t||e&&t.depth>=e.depth?(s=e,e=e.next):(s=t,t=t.next),n&&n.mode==s.mode&&!s.context&&!n.context)continue;let a=new Dc(s.tags,s.mode,s.context);n?n.next=a:r=a,n=a}return r}});class Dc{constructor(e,n,r,s){this.tags=e,this.mode=n,this.context=r,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let c=s;for(let u of a)for(let f of u.set){let h=n[f.id];if(h){c=c?c+" "+h:h;break}}return c},scope:r}}const je=yi.define,_c=je(),Fr=je(),zx=je(Fr),Ux=je(Fr),Pr=je(),Lc=je(Pr),Mh=je(Pr),Yi=je(),Ls=je(Yi),Ki=je(),Gi=je(),Rh=je(),qa=je(Rh),qc=je(),rt={comment:_c,lineComment:je(_c),blockComment:je(_c),docComment:je(_c),name:Fr,variableName:je(Fr),typeName:zx,tagName:je(zx),propertyName:Ux,attributeName:je(Ux),className:je(Fr),labelName:je(Fr),namespace:je(Fr),macroName:je(Fr),literal:Pr,string:Lc,docString:je(Lc),character:je(Lc),attributeValue:je(Lc),number:Mh,integer:je(Mh),float:je(Mh),bool:je(Pr),regexp:je(Pr),escape:je(Pr),color:je(Pr),url:je(Pr),keyword:Ki,self:je(Ki),null:je(Ki),atom:je(Ki),unit:je(Ki),modifier:je(Ki),operatorKeyword:je(Ki),controlKeyword:je(Ki),definitionKeyword:je(Ki),moduleKeyword:je(Ki),operator:Gi,derefOperator:je(Gi),arithmeticOperator:je(Gi),logicOperator:je(Gi),bitwiseOperator:je(Gi),compareOperator:je(Gi),updateOperator:je(Gi),definitionOperator:je(Gi),typeOperator:je(Gi),controlOperator:je(Gi),punctuation:Rh,separator:je(Rh),bracket:qa,angleBracket:je(qa),squareBracket:je(qa),paren:je(qa),brace:je(qa),content:Yi,heading:Ls,heading1:je(Ls),heading2:je(Ls),heading3:je(Ls),heading4:je(Ls),heading5:je(Ls),heading6:je(Ls),contentSeparator:je(Yi),list:je(Yi),quote:je(Yi),emphasis:je(Yi),strong:je(Yi),link:je(Yi),monospace:je(Yi),strikethrough:je(Yi),inserted:je(),deleted:je(),changed:je(),invalid:je(),meta:qc,documentMeta:je(qc),annotation:je(qc),processingInstruction:je(qc),definition:yi.defineModifier("definition"),constant:yi.defineModifier("constant"),function:yi.defineModifier("function"),standard:yi.defineModifier("standard"),local:yi.defineModifier("local"),special:yi.defineModifier("special")};for(let t in rt){let e=rt[t];e instanceof yi&&(e.name=t)}dE([{tag:rt.link,class:"tok-link"},{tag:rt.heading,class:"tok-heading"},{tag:rt.emphasis,class:"tok-emphasis"},{tag:rt.strong,class:"tok-strong"},{tag:rt.keyword,class:"tok-keyword"},{tag:rt.atom,class:"tok-atom"},{tag:rt.bool,class:"tok-bool"},{tag:rt.url,class:"tok-url"},{tag:rt.labelName,class:"tok-labelName"},{tag:rt.inserted,class:"tok-inserted"},{tag:rt.deleted,class:"tok-deleted"},{tag:rt.literal,class:"tok-literal"},{tag:rt.string,class:"tok-string"},{tag:rt.number,class:"tok-number"},{tag:[rt.regexp,rt.escape,rt.special(rt.string)],class:"tok-string2"},{tag:rt.variableName,class:"tok-variableName"},{tag:rt.local(rt.variableName),class:"tok-variableName tok-local"},{tag:rt.definition(rt.variableName),class:"tok-variableName tok-definition"},{tag:rt.special(rt.variableName),class:"tok-variableName2"},{tag:rt.definition(rt.propertyName),class:"tok-propertyName tok-definition"},{tag:rt.typeName,class:"tok-typeName"},{tag:rt.namespace,class:"tok-namespace"},{tag:rt.className,class:"tok-className"},{tag:rt.macroName,class:"tok-macroName"},{tag:rt.propertyName,class:"tok-propertyName"},{tag:rt.operator,class:"tok-operator"},{tag:rt.comment,class:"tok-comment"},{tag:rt.meta,class:"tok-meta"},{tag:rt.invalid,class:"tok-invalid"},{tag:rt.punctuation,class:"tok-punctuation"}]);var Dh;const Bc=new gt,fE=new gt;class or{constructor(e,n,r=[],s=""){this.data=e,this.name=s,St.prototype.hasOwnProperty("tree")||Object.defineProperty(St.prototype,"tree",{get(){return Yr(this)}}),this.parser=n,this.extension=[xl.of(this),St.languageData.of((a,c,u)=>{let f=Vx(a,c,u),h=f.type.prop(Bc);if(!h)return[];let g=a.facet(h),b=f.type.prop(fE);if(b){let v=f.resolve(c-f.from,u);for(let w of b)if(w.test(v,a)){let A=a.facet(w.facet);return w.type=="replace"?A:A.concat(g)}}return g})].concat(r)}isActiveAt(e,n,r=-1){return Vx(e,n,r).type.prop(Bc)==this.data}findRegions(e){let n=e.facet(xl);if(n?.data==this.data)return[{from:0,to:e.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],s=(a,c)=>{if(a.prop(Bc)==this.data){r.push({from:c,to:c+a.length});return}let u=a.prop(gt.mounted);if(u){if(u.tree.prop(Bc)==this.data){if(u.overlay)for(let f of u.overlay)r.push({from:f.from+c,to:f.to+c});else r.push({from:c,to:c+a.length});return}else if(u.overlay){let f=r.length;if(s(u.tree,u.overlay[0].from+c),r.length>f)return}}for(let f=0;f=this.cursorPos?this.doc.sliceString(e,n):this.string.slice(e-r,n-r)}}let Ba=null;class $c{constructor(e,n,r=[],s,a,c,u,f){this.parser=e,this.state=n,this.fragments=r,this.tree=s,this.treeLen=a,this.viewport=c,this.skipped=u,this.scheduleOn=f,this.parse=null,this.tempSkipped=[]}static create(e,n,r){return new $c(e,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new hE(this.state.doc),this.fragments)}work(e,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.empty&&this.isDone(n??this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var r;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),n!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>n)&&n=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(n=this.parse.advance()););}),this.treeLen=e,this.tree=n,this.fragments=this.withoutTempSkipped(_s.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let n=Ba;Ba=this;try{return e()}finally{Ba=n}}withoutTempSkipped(e){for(let n;n=this.tempSkipped.pop();)e=Fx(e,n.from,n.to);return e}changes(e,n){let{fragments:r,tree:s,treeLen:a,viewport:c,skipped:u}=this;if(this.takeTree(),!e.empty){let f=[];if(e.iterChangedRanges((h,g,b,v)=>f.push({fromA:h,toA:g,fromB:b,toB:v})),r=_s.applyChanges(r,f),s=pn.empty,a=0,c={from:e.mapPos(c.from,-1),to:e.mapPos(c.to,1)},this.skipped.length){u=[];for(let h of this.skipped){let g=e.mapPos(h.from,1),b=e.mapPos(h.to,-1);ge.from&&(this.fragments=Fx(this.fragments,s,a),this.skipped.splice(r--,1))}return this.skipped.length>=n?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,n){this.skipped.push({from:e,to:n})}static getSkippingParser(e){return new class extends iE{createParse(n,r,s){let a=s[0].from,c=s[s.length-1].to;return{parsedPos:a,advance(){let f=Ba;if(f){for(let h of s)f.tempSkipped.push(h);e&&(f.scheduleOn=f.scheduleOn?Promise.all([f.scheduleOn,e]):e)}return this.parsedPos=c,new pn(mi.none,[],[],c-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let n=this.fragments;return this.treeLen>=e&&n.length&&n[0].from==0&&n[0].to>=e}static get(){return Ba}}function Fx(t,e,n){return _s.applyChanges(t,[{fromA:e,toA:n,fromB:e,toB:n}])}class bl{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let n=this.context.changes(e.changes,e.state),r=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),n.viewport.to);return n.work(20,r)||n.takeTree(),new bl(n)}static init(e){let n=Math.min(3e3,e.doc.length),r=$c.create(e.facet(xl).parser,e,{from:0,to:n});return r.work(20,n)||r.takeTree(),new bl(r)}}or.state=qr.define({create:bl.init,update(t,e){for(let n of e.effects)if(n.is(or.setState))return n.value;return e.startState.facet(xl)!=e.state.facet(xl)?bl.init(e.state):t.apply(e)}});let Px=t=>{let e=setTimeout(()=>t(),500);return()=>clearTimeout(e)};typeof requestIdleCallback<"u"&&(Px=t=>{let e=-1,n=setTimeout(()=>{e=requestIdleCallback(t,{timeout:400})},100);return()=>e<0?clearTimeout(n):cancelIdleCallback(e)});const _h=typeof navigator<"u"&&(!((Dh=navigator.scheduling)===null||Dh===void 0)&&Dh.isInputPending)?()=>navigator.scheduling.isInputPending():null,pE=lr.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 n=this.view.state.field(or.state).context;(n.updateViewport(e.view.viewport)||this.view.viewport.to>n.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(n)}scheduleWork(){if(this.working)return;let{state:e}=this.view,n=e.field(or.state);(n.tree!=n.context.tree||!n.context.isDone(e.doc.length))&&(this.working=Px(this.work))}work(e){this.working=null;let n=Date.now();if(this.chunkEnds+1e3,f=a.context.work(()=>_h&&_h()||Date.now()>c,s+(u?0:1e5));this.chunkBudget-=Date.now()-n,(f||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:or.setState.of(new bl(a.context))})),this.chunkBudget>0&&!(f&&!u)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(n=>Fi(this.view.state,n)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),xl=Ue.define({combine(t){return t.length?t[0]:null},enables:t=>[or.state,pE,Xe.contentAttributes.compute([t],e=>{let n=e.facet(t);return n&&n.name?{"data-language":n.name}:{}})]}),mE=Ue.define(),Lh=Ue.define({combine:t=>{if(!t.length)return" ";let e=t[0];if(!e||/\S/.test(e)||Array.from(e).some(n=>n!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(t[0]));return e}});function Ic(t){let e=t.facet(Lh);return e.charCodeAt(0)==9?t.tabSize*e.length:e.length}function Hc(t,e){let n="",r=t.tabSize,s=t.facet(Lh)[0];if(s==" "){for(;e>=r;)n+=" ",e-=r;s=" "}for(let a=0;a=e?yE(t,n,e):null}class zc{constructor(e,n={}){this.state=e,this.options=n,this.unit=Ic(e)}lineAt(e,n=1){let r=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=r.from&&s<=r.to?a&&s==e?{text:"",from:e}:(n<0?s-1&&(a+=c-this.countColumn(r,r.search(/\S|$/))),a}countColumn(e,n=e.length){return tc(e,this.state.tabSize,n)}lineIndent(e,n=1){let{text:r,from:s}=this.lineAt(e,n),a=this.options.overrideIndentation;if(a){let c=a(s);if(c>-1)return c}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const gE=new gt;function yE(t,e,n){let r=e.resolveStack(n),s=e.resolveInner(n,-1).resolve(n,0).enterUnfinishedNodesBefore(n);if(s!=r.node){let a=[];for(let c=s;c&&!(c.fromr.node.to||c.from==r.node.from&&c.type==r.node.type);c=c.parent)a.push(c);for(let c=a.length-1;c>=0;c--)r={node:a[c],next:r}}return Kx(r,t,n)}function Kx(t,e,n){for(let r=t;r;r=r.next){let s=xE(r.node);if(s)return s(qh.create(e,n,r))}return 0}function bE(t){return t.pos==t.options.simulateBreak&&t.options.simulateDoubleBreak}function xE(t){let e=t.type.prop(gE);if(e)return e;let n=t.firstChild,r;if(n&&(r=n.type.prop(gt.closedBy))){let s=t.lastChild,a=s&&r.indexOf(s.name)>-1;return c=>AE(c,!0,1,void 0,a&&!bE(c)?s.from:void 0)}return t.parent==null?vE:null}function vE(){return 0}class qh extends zc{constructor(e,n,r){super(e.state,e.options),this.base=e,this.pos=n,this.context=r}get node(){return this.context.node}static create(e,n,r){return new qh(e,n,r)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let n=this.state.doc.lineAt(e.from);for(;;){let r=e.resolve(n.from);for(;r.parent&&r.parent.from==r.from;)r=r.parent;if(wE(r,e))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Kx(this.context.next,this.base,this.pos)}}function wE(t,e){for(let n=e;n;n=n.parent)if(t==n)return!0;return!1}function SE(t){let e=t.node,n=e.childAfter(e.from),r=e.lastChild;if(!n)return null;let s=t.options.simulateBreak,a=t.state.doc.lineAt(n.from),c=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let u=n.to;;){let f=e.childAfter(u);if(!f||f==r)return null;if(!f.type.isSkipped){if(f.from>=c)return null;let h=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+h}}u=f.to}}function AE(t,e,n,r,s){let a=t.textAfter,c=a.match(/^\s*/)[0].length,u=r&&a.slice(c,c+r.length)==r||s==t.pos+c,f=SE(t);return f?u?t.column(f.from):t.column(f.to):t.baseIndent+(u?0:t.unit*n)}const kE=1e4,CE="()[]{}",NE=new gt;function Bh(t,e,n){let r=t.prop(e<0?gt.openedBy:gt.closedBy);if(r)return r;if(t.name.length==1){let s=n.indexOf(t.name);if(s>-1&&s%2==(e<0?1:0))return[n[s+e]]}return null}function $h(t){let e=t.type.prop(NE);return e?e(t.node):t}function vl(t,e,n,r={}){let s=r.maxScanDistance||kE,a=r.brackets||CE,c=Yr(t),u=c.resolveInner(e,n);for(let f=u;f;f=f.parent){let h=Bh(f.type,n,a);if(h&&f.from0?e>=g.from&&eg.from&&e<=g.to))return TE(t,e,n,f,g,h,a)}}return jE(t,e,n,c,u.type,s,a)}function TE(t,e,n,r,s,a,c){let u=r.parent,f={from:s.from,to:s.to},h=0,g=u?.cursor();if(g&&(n<0?g.childBefore(r.from):g.childAfter(r.to)))do if(n<0?g.to<=r.from:g.from>=r.to){if(h==0&&a.indexOf(g.type.name)>-1&&g.from0)return null;let h={from:n<0?e-1:e,to:n>0?e+1:e},g=t.doc.iterRange(e,n>0?t.doc.length:0),b=0;for(let v=0;!g.next().done&&v<=a;){let w=g.value;n<0&&(v+=w.length);let A=e+v*n;for(let C=n>0?0:w.length-1,E=n>0?w.length:-1;C!=E;C+=n){let D=c.indexOf(w[C]);if(!(D<0||r.resolveInner(A+C,1).type!=s))if(D%2==0==n>0)b++;else{if(b==1)return{start:h,end:{from:A+C,to:A+C+1},matched:D>>1==f>>1};b--}}n>0&&(v+=w.length)}return g.done?{start:h,matched:!1}:null}const EE=Object.create(null),Gx=[mi.none],Xx=[],Jx=Object.create(null),OE=Object.create(null);for(let[t,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])OE[t]=ME(EE,e);function Ih(t,e){Xx.indexOf(t)>-1||(Xx.push(t),console.warn(e))}function ME(t,e){let n=[];for(let u of e.split(" ")){let f=[];for(let h of u.split(".")){let g=t[h]||rt[h];g?typeof g=="function"?f.length?f=f.map(g):Ih(h,`Modifier ${h} used at start of tag`):f.length?Ih(h,`Tag ${h} used as modifier`):f=Array.isArray(g)?g:[g]:Ih(h,`Unknown highlighting tag ${h}`)}for(let h of f)n.push(h)}if(!n.length)return 0;let r=e.replace(/ /g,"_"),s=r+" "+n.map(u=>u.id),a=Jx[s];if(a)return a.id;let c=Jx[s]=mi.define({id:Gx.length,name:r,props:[cE({[r]:n})]});return Gx.push(c),c.id}Bt.RTL,Bt.LTR;const RE=t=>{let{state:e}=t,n=e.doc.lineAt(e.selection.main.from),r=zh(t.state,n.from);return r.line?DE(t):r.block?LE(t):!1};function Hh(t,e){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let s=t(e,n);return s?(r(n.update(s)),!0):!1}}const DE=Hh($E,0),_E=Hh(Qx,0),LE=Hh((t,e)=>Qx(t,e,BE(e)),0);function zh(t,e){let n=t.languageDataAt("commentTokens",e,1);return n.length?n[0]:{}}const $a=50;function qE(t,{open:e,close:n},r,s){let a=t.sliceDoc(r-$a,r),c=t.sliceDoc(s,s+$a),u=/\s*$/.exec(a)[0].length,f=/^\s*/.exec(c)[0].length,h=a.length-u;if(a.slice(h-e.length,h)==e&&c.slice(f,f+n.length)==n)return{open:{pos:r-u,margin:u&&1},close:{pos:s+f,margin:f&&1}};let g,b;s-r<=2*$a?g=b=t.sliceDoc(r,s):(g=t.sliceDoc(r,r+$a),b=t.sliceDoc(s-$a,s));let v=/^\s*/.exec(g)[0].length,w=/\s*$/.exec(b)[0].length,A=b.length-w-n.length;return g.slice(v,v+e.length)==e&&b.slice(A,A+n.length)==n?{open:{pos:r+v+e.length,margin:/\s/.test(g.charAt(v+e.length))?1:0},close:{pos:s-w-n.length,margin:/\s/.test(b.charAt(A-1))?1:0}}:null}function BE(t){let e=[];for(let n of t.selection.ranges){let r=t.doc.lineAt(n.from),s=n.to<=r.to?r:t.doc.lineAt(n.to);s.from>r.from&&s.from==n.to&&(s=n.to==r.to+1?r:t.doc.lineAt(n.to-1));let a=e.length-1;a>=0&&e[a].to>r.from?e[a].to=s.to:e.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:s.to})}return e}function Qx(t,e,n=e.selection.ranges){let r=n.map(a=>zh(e,a.from).block);if(!r.every(a=>a))return null;let s=n.map((a,c)=>qE(e,r[c],a.from,a.to));if(t!=2&&!s.every(a=>a))return{changes:e.changes(n.map((a,c)=>s[c]?[]:[{from:a.from,insert:r[c].open+" "},{from:a.to,insert:" "+r[c].close}]))};if(t!=1&&s.some(a=>a)){let a=[];for(let c=0,u;cs&&(a==c||c>b.from)){s=b.from;let v=/^\s*/.exec(b.text)[0].length,w=v==b.length,A=b.text.slice(v,v+h.length)==h?v:-1;va.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:u,token:f,indent:h,empty:g,single:b}of r)(b||!g)&&a.push({from:u.from+h,insert:f+" "});let c=e.changes(a);return{changes:c,selection:e.selection.map(c,1)}}else if(t!=1&&r.some(a=>a.comment>=0)){let a=[];for(let{line:c,comment:u,token:f}of r)if(u>=0){let h=c.from+u,g=h+f.length;c.text[g-c.from]==" "&&g++,a.push({from:h,to:g})}return{changes:a}}return null}const Uh=Br.define(),IE=Br.define(),HE=Ue.define(),Wx=Ue.define({combine(t){return Mf(t,{minDepth:100,newGroupDelay:500,joinToEvent:(e,n)=>n},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,n)=>(r,s)=>e(r,s)||n(r,s)})}}),Zx=qr.define({create(){return Xi.empty},update(t,e){let n=e.state.facet(Wx),r=e.annotation(Uh);if(r){let f=zn.fromTransaction(e,r.selection),h=r.side,g=h==0?t.undone:t.done;return f?g=Vc(g,g.length,n.minDepth,f):g=nv(g,e.startState.selection),new Xi(h==0?r.rest:g,h==0?g:r.rest)}let s=e.annotation(IE);if((s=="full"||s=="before")&&(t=t.isolate()),e.annotation(rn.addToHistory)===!1)return e.changes.empty?t:t.addMapping(e.changes.desc);let a=zn.fromTransaction(e),c=e.annotation(rn.time),u=e.annotation(rn.userEvent);return a?t=t.addChanges(a,c,u,n,e):e.selection&&(t=t.addSelection(e.startState.selection,c,u,n.newGroupDelay)),(s=="full"||s=="after")&&(t=t.isolate()),t},toJSON(t){return{done:t.done.map(e=>e.toJSON()),undone:t.undone.map(e=>e.toJSON())}},fromJSON(t){return new Xi(t.done.map(zn.fromJSON),t.undone.map(zn.fromJSON))}});function zE(t={}){return[Zx,Wx.of(t),Xe.domEventHandlers({beforeinput(e,n){let r=e.inputType=="historyUndo"?ev:e.inputType=="historyRedo"?Vh:null;return r?(e.preventDefault(),r(n)):!1}})]}function Uc(t,e){return function({state:n,dispatch:r}){if(!e&&n.readOnly)return!1;let s=n.field(Zx,!1);if(!s)return!1;let a=s.pop(t,n,e);return a?(r(a),!0):!1}}const ev=Uc(0,!1),Vh=Uc(1,!1),UE=Uc(0,!0),VE=Uc(1,!0);class zn{constructor(e,n,r,s,a){this.changes=e,this.effects=n,this.mapped=r,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new zn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,n,r;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(n=this.mapped)===null||n===void 0?void 0:n.toJSON(),startSelection:(r=this.startSelection)===null||r===void 0?void 0:r.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new zn(e.changes&&nn.fromJSON(e.changes),[],e.mapped&&zi.fromJSON(e.mapped),e.startSelection&&ke.fromJSON(e.startSelection),e.selectionsAfter.map(ke.fromJSON))}static fromTransaction(e,n){let r=bi;for(let s of e.startState.facet(HE)){let a=s(e);a.length&&(r=r.concat(a))}return!r.length&&e.changes.empty?null:new zn(e.changes.invert(e.startState.doc),r,void 0,n||e.startState.selection,bi)}static selection(e){return new zn(void 0,bi,void 0,void 0,e)}}function Vc(t,e,n,r){let s=e+1>n+20?e-n-1:0,a=t.slice(s,e);return a.push(r),a}function FE(t,e){let n=[],r=!1;return t.iterChangedRanges((s,a)=>n.push(s,a)),e.iterChangedRanges((s,a,c,u)=>{for(let f=0;f=h&&c<=g&&(r=!0)}}),r}function PE(t,e){return t.ranges.length==e.ranges.length&&t.ranges.filter((n,r)=>n.empty!=e.ranges[r].empty).length===0}function tv(t,e){return t.length?e.length?t.concat(e):t:e}const bi=[],YE=200;function nv(t,e){if(t.length){let n=t[t.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-YE));return r.length&&r[r.length-1].eq(e)?t:(r.push(e),Vc(t,t.length-1,1e9,n.setSelAfter(r)))}else return[zn.selection([e])]}function KE(t){let e=t[t.length-1],n=t.slice();return n[t.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),n}function Fh(t,e){if(!t.length)return t;let n=t.length,r=bi;for(;n;){let s=GE(t[n-1],e,r);if(s.changes&&!s.changes.empty||s.effects.length){let a=t.slice(0,n);return a[n-1]=s,a}else e=s.mapped,n--,r=s.selectionsAfter}return r.length?[zn.selection(r)]:bi}function GE(t,e,n){let r=tv(t.selectionsAfter.length?t.selectionsAfter.map(u=>u.map(e)):bi,n);if(!t.changes)return zn.selection(r);let s=t.changes.map(e),a=e.mapDesc(t.changes,!0),c=t.mapped?t.mapped.composeDesc(a):a;return new zn(s,Ft.mapEffects(t.effects,e),c,t.startSelection.map(a),r)}const XE=/^(input\.type|delete)($|\.)/;class Xi{constructor(e,n,r=0,s=void 0){this.done=e,this.undone=n,this.prevTime=r,this.prevUserEvent=s}isolate(){return this.prevTime?new Xi(this.done,this.undone):this}addChanges(e,n,r,s,a){let c=this.done,u=c[c.length-1];return u&&u.changes&&!u.changes.empty&&e.changes&&(!r||XE.test(r))&&(!u.selectionsAfter.length&&n-this.prevTime0&&n-this.prevTimen.empty?t.moveByChar(n,e):Fc(n,e))}function Nn(t){return t.textDirectionAt(t.state.selection.main.head)==Bt.LTR}const sv=t=>rv(t,!Nn(t)),lv=t=>rv(t,Nn(t));function av(t,e){return _i(t,n=>n.empty?t.moveByGroup(n,e):Fc(n,e))}const JE=t=>av(t,!Nn(t)),QE=t=>av(t,Nn(t));function WE(t,e,n){if(e.type.prop(n))return!0;let r=e.to-e.from;return r&&(r>2||/[^\s,.;:]/.test(t.sliceDoc(e.from,e.to)))||e.firstChild}function Pc(t,e,n){let r=Yr(t).resolveInner(e.head),s=n?gt.closedBy:gt.openedBy;for(let f=e.head;;){let h=n?r.childAfter(f):r.childBefore(f);if(!h)break;WE(t,h,s)?r=h:f=n?h.to:h.from}let a=r.type.prop(s),c,u;return a&&(c=n?vl(t,r.from,1):vl(t,r.to,-1))&&c.matched?u=n?c.end.to:c.end.from:u=n?r.to:r.from,ke.cursor(u,n?-1:1)}const ZE=t=>_i(t,e=>Pc(t.state,e,!Nn(t))),eO=t=>_i(t,e=>Pc(t.state,e,Nn(t)));function ov(t,e){return _i(t,n=>{if(!n.empty)return Fc(n,e);let r=t.moveVertically(n,e);return r.head!=n.head?r:t.moveToLineBoundary(n,e)})}const cv=t=>ov(t,!1),uv=t=>ov(t,!0);function dv(t){let e=t.scrollDOM.clientHeightc.empty?t.moveVertically(c,e,n.height):Fc(c,e));if(s.eq(r.selection))return!1;let a;if(n.selfScroll){let c=t.coordsAtPos(r.selection.main.head),u=t.scrollDOM.getBoundingClientRect(),f=u.top+n.marginTop,h=u.bottom-n.marginBottom;c&&c.top>f&&c.bottomfv(t,!1),Ph=t=>fv(t,!0);function Kr(t,e,n){let r=t.lineBlockAt(e.head),s=t.moveToLineBoundary(e,n);if(s.head==e.head&&s.head!=(n?r.to:r.from)&&(s=t.moveToLineBoundary(e,n,!1)),!n&&s.head==r.from&&r.length){let a=/^\s*/.exec(t.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;a&&e.head!=r.from+a&&(s=ke.cursor(r.from+a))}return s}const tO=t=>_i(t,e=>Kr(t,e,!0)),nO=t=>_i(t,e=>Kr(t,e,!1)),iO=t=>_i(t,e=>Kr(t,e,!Nn(t))),rO=t=>_i(t,e=>Kr(t,e,Nn(t))),sO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).from,1)),lO=t=>_i(t,e=>ke.cursor(t.lineBlockAt(e.head).to,-1));function aO(t,e,n){let r=!1,s=wl(t.selection,a=>{let c=vl(t,a.head,-1)||vl(t,a.head,1)||a.head>0&&vl(t,a.head-1,1)||a.headaO(t,e);function xi(t,e,n){let r=wl(t.state.selection,s=>{s.undirectional&&s.head>=s.anchor!=e&&(s=ke.range(s.head,s.anchor));let a=n(s);return ke.range(s.anchor,a.head,a.goalColumn,a.bidiLevel||void 0,a.assoc)});return r.eq(t.state.selection)?!1:(t.dispatch(Di(t.state,r)),!0)}function pv(t,e){return xi(t,e,n=>t.moveByChar(n,e))}const mv=t=>pv(t,!Nn(t)),gv=t=>pv(t,Nn(t));function yv(t,e){return xi(t,e,n=>t.moveByGroup(n,e))}const cO=t=>yv(t,!Nn(t)),uO=t=>yv(t,Nn(t)),dO=t=>{let e=!Nn(t);return xi(t,e,n=>Pc(t.state,n,e))},fO=t=>{let e=Nn(t);return xi(t,e,n=>Pc(t.state,n,e))};function bv(t,e){return xi(t,e,n=>t.moveVertically(n,e))}const xv=t=>bv(t,!1),vv=t=>bv(t,!0);function wv(t,e){return xi(t,e,n=>t.moveVertically(n,e,dv(t).height))}const Sv=t=>wv(t,!1),Av=t=>wv(t,!0),hO=t=>xi(t,!0,e=>Kr(t,e,!0)),pO=t=>xi(t,!1,e=>Kr(t,e,!1)),mO=t=>{let e=!Nn(t);return xi(t,e,n=>Kr(t,n,e))},gO=t=>{let e=Nn(t);return xi(t,e,n=>Kr(t,n,e))},yO=t=>xi(t,!1,e=>ke.cursor(t.lineBlockAt(e.head).from)),bO=t=>xi(t,!0,e=>ke.cursor(t.lineBlockAt(e.head).to)),kv=({state:t,dispatch:e})=>(e(Di(t,{anchor:0})),!0),Cv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.doc.length})),!0),Nv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:0})),!0),Tv=({state:t,dispatch:e})=>(e(Di(t,{anchor:t.selection.main.anchor,head:t.doc.length})),!0),xO=({state:t,dispatch:e})=>(e(t.update({selection:{anchor:0,head:t.doc.length},userEvent:"select"})),!0),vO=({state:t,dispatch:e})=>{let n=Kc(t).map(({from:r,to:s})=>ke.undirectionalRange(r,Math.min(s+1,t.doc.length)));return e(t.update({selection:ke.create(n),userEvent:"select"})),!0},wO=({state:t,dispatch:e})=>{let n=wl(t.selection,r=>{let s=Yr(t),a=s.resolveStack(r.from,1);if(r.empty){let c=s.resolveStack(r.from,-1);c.node.from>=a.node.from&&c.node.to<=a.node.to&&(a=c)}for(let c=a;c;c=c.next){let{node:u}=c;if((u.from=r.to||u.to>r.to&&u.from<=r.from)&&c.next)return ke.undirectionalRange(u.from,u.to)}return r});return n.eq(t.selection)?!1:(e(Di(t,n)),!0)};function jv(t,e){let{state:n}=t,r=n.selection,s=n.selection.ranges.slice();for(let a of n.selection.ranges){let c=n.doc.lineAt(a.head);if(e?c.to0)for(let u=a;;){let f=t.moveVertically(u,e);if(f.headc.to){s.some(h=>h.head==f.head)||s.push(f);break}else{if(f.head==u.head)break;u=f}}}return s.length==r.ranges.length?!1:(t.dispatch(Di(n,ke.create(s,s.length-1))),!0)}const SO=t=>jv(t,!1),AO=t=>jv(t,!0),kO=({state:t,dispatch:e})=>{let n=t.selection,r=null;return n.ranges.length>1?r=ke.create([n.main]):n.main.empty||(r=ke.create([ke.cursor(n.main.head)])),r?(e(Di(t,r)),!0):!1};function Ia(t,e){if(t.state.readOnly)return!1;let n="delete.selection",{state:r}=t,s=r.changeByRange(a=>{let{from:c,to:u}=a;if(c==u){let f=e(a);fc&&(n="delete.forward",f=Yc(t,f,!0)),c=Math.min(c,f),u=Math.max(u,f)}else c=Yc(t,c,!1),u=Yc(t,u,!0);return c==u?{range:a}:{changes:{from:c,to:u},range:ke.cursor(c,cs(t)))r.between(e,e,(s,a)=>{se&&(e=n?a:s)});return e}const Ev=(t,e,n)=>Ia(t,r=>{let s=r.from,{state:a}=t,c=a.doc.lineAt(s),u,f;if(n&&!e&&s>c.from&&sEv(t,!1,!0),Ov=t=>Ev(t,!0,!1),Mv=(t,e)=>Ia(t,n=>{let r=n.head,{state:s}=t,a=s.doc.lineAt(r),c=s.charCategorizer(r);for(let u=null;;){if(r==(e?a.to:a.from)){r==n.head&&a.number!=(e?s.doc.lines:1)&&(r+=e?1:-1);break}let f=kn(a.text,r-a.from,e)+a.from,h=a.text.slice(Math.min(r,f)-a.from,Math.max(r,f)-a.from),g=c(h);if(u!=null&&g!=u)break;(h!=" "||r!=n.head)&&(u=g),r=f}return r}),Rv=t=>Mv(t,!1),CO=t=>Mv(t,!0),NO=t=>Ia(t,e=>{let n=t.lineBlockAt(e.head).to;return e.headIa(t,e=>{let n=t.moveToLineBoundary(e,!1).head;return e.head>n?n:Math.max(0,e.head-1)}),jO=t=>Ia(t,e=>{let n=t.moveToLineBoundary(e,!0).head;return e.head{if(t.readOnly)return!1;let n=t.changeByRange(r=>({changes:{from:r.from,to:r.to,insert:mt.of(["",""])},range:ke.cursor(r.from)}));return e(t.update(n,{scrollIntoView:!0,userEvent:"input"})),!0},OO=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=t.changeByRange(r=>{if(!r.empty||r.from==0||r.from==t.doc.length)return{range:r};let s=r.from,a=t.doc.lineAt(s),c=s==a.from?s-1:kn(a.text,s-a.from,!1)+a.from,u=s==a.to?s+1:kn(a.text,s-a.from,!0)+a.from;return{changes:{from:c,to:u,insert:t.doc.slice(s,u).append(t.doc.slice(c,s))},range:ke.cursor(u)}});return n.changes.empty?!1:(e(t.update(n,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function Kc(t){let e=[],n=-1;for(let r of t.selection.ranges){let s=t.doc.lineAt(r.from),a=t.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=t.doc.lineAt(r.to-1)),n>=s.number){let c=e[e.length-1];c.to=a.to,c.ranges.push(r)}else e.push({from:s.from,to:a.to,ranges:[r]});n=a.number+1}return e}function Dv(t,e,n){if(t.readOnly)return!1;let r=[],s=[];for(let a of Kc(t)){if(n?a.to==t.doc.length:a.from==0)continue;let c=t.doc.lineAt(n?a.to+1:a.from-1),u=c.length+1;if(n){r.push({from:a.to,to:c.to},{from:a.from,insert:c.text+t.lineBreak});for(let f of a.ranges)s.push(ke.range(Math.min(t.doc.length,f.anchor+u),Math.min(t.doc.length,f.head+u)))}else{r.push({from:c.from,to:a.from},{from:a.to,insert:t.lineBreak+c.text});for(let f of a.ranges)s.push(ke.range(f.anchor-u,f.head-u))}}return r.length?(e(t.update({changes:r,scrollIntoView:!0,selection:ke.create(s,t.selection.mainIndex),userEvent:"move.line"})),!0):!1}const MO=({state:t,dispatch:e})=>Dv(t,e,!1),RO=({state:t,dispatch:e})=>Dv(t,e,!0);function _v(t,e,n){if(t.readOnly)return!1;let r=[];for(let a of Kc(t))n?r.push({from:a.from,insert:t.doc.slice(a.from,a.to)+t.lineBreak}):r.push({from:a.to,insert:t.lineBreak+t.doc.slice(a.from,a.to)});let s=t.changes(r);return e(t.update({changes:s,selection:t.selection.map(s,n?1:-1),scrollIntoView:!0,userEvent:"input.copyline"})),!0}const DO=({state:t,dispatch:e})=>_v(t,e,!1),_O=({state:t,dispatch:e})=>_v(t,e,!0),LO=t=>{if(t.state.readOnly)return!1;let{state:e}=t,n=e.changes(Kc(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(t.lineWrapping){let c=t.lineBlockAt(s.head),u=t.coordsAtPos(s.head,s.assoc||1);u&&(a=c.bottom+t.documentTop-u.bottom+t.defaultLineHeight/2)}return t.moveVertically(s,!0,a)}).map(n);return t.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:"delete.line"}),!0};function qO(t,e){if(/\(\)|\[\]|\{\}/.test(t.sliceDoc(e-1,e+1)))return{from:e,to:e};let n=Yr(t).resolveInner(e),r=n.childBefore(e),s=n.childAfter(e),a;return r&&s&&r.to<=e&&s.from>=e&&(a=r.type.prop(gt.closedBy))&&a.indexOf(s.name)>-1&&t.doc.lineAt(r.to).from==t.doc.lineAt(s.from).from&&!/\S/.test(t.sliceDoc(r.to,s.from))?{from:r.to,to:s.from}:null}const Lv=qv(!1),BO=qv(!0);function qv(t){return({state:e,dispatch:n})=>{if(e.readOnly)return!1;let r=e.changeByRange(s=>{let{from:a,to:c}=s,u=e.doc.lineAt(a),f=!t&&a==c&&qO(e,a);t&&(a=c=(c<=u.to?u:e.doc.lineAt(c)).to);let h=new zc(e,{simulateBreak:a,simulateDoubleBreak:!!f}),g=Yx(h,a);for(g==null&&(g=tc(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));cu.from&&a{let s=[];for(let c=r.from;c<=r.to;){let u=t.doc.lineAt(c);u.number>n&&(r.empty||r.to>u.from)&&(e(u,s,r),n=u.number),c=u.to+1}let a=t.changes(s);return{changes:s,range:ke.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}const $O=({state:t,dispatch:e})=>{if(t.readOnly)return!1;let n=Object.create(null),r=new zc(t,{overrideIndentation:a=>{let c=n[a];return c??-1}}),s=Kh(t,(a,c,u)=>{let f=Yx(r,a.from);if(f==null)return;/\S/.test(a.text)||(f=0);let h=/^\s*/.exec(a.text)[0],g=Hc(t,f);(h!=g||u.fromt.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{r.push({from:n.from,insert:t.facet(Lh)})}),{userEvent:"input.indent"})),!0),$v=({state:t,dispatch:e})=>t.readOnly?!1:(e(t.update(Kh(t,(n,r)=>{let s=/^\s*/.exec(n.text)[0];if(!s)return;let a=tc(s,t.tabSize),c=0,u=Hc(t,Math.max(0,a-Ic(t)));for(;c(t.setTabFocusMode(),!0),HO=[{key:"Ctrl-b",run:sv,shift:mv,preventDefault:!0},{key:"Ctrl-f",run:lv,shift:gv},{key:"Ctrl-p",run:cv,shift:xv},{key:"Ctrl-n",run:uv,shift:vv},{key:"Ctrl-a",run:sO,shift:yO},{key:"Ctrl-e",run:lO,shift:bO},{key:"Ctrl-d",run:Ov},{key:"Ctrl-h",run:Yh},{key:"Ctrl-k",run:NO},{key:"Ctrl-Alt-h",run:Rv},{key:"Ctrl-o",run:EO},{key:"Ctrl-t",run:OO},{key:"Ctrl-v",run:Ph}],zO=[{key:"ArrowLeft",run:sv,shift:mv,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:JE,shift:cO,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:iO,shift:mO,preventDefault:!0},{key:"ArrowRight",run:lv,shift:gv,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:QE,shift:uO,preventDefault:!0},{mac:"Cmd-ArrowRight",run:rO,shift:gO,preventDefault:!0},{key:"ArrowUp",run:cv,shift:xv,preventDefault:!0},{mac:"Cmd-ArrowUp",run:kv,shift:Nv},{mac:"Ctrl-ArrowUp",run:hv,shift:Sv},{key:"ArrowDown",run:uv,shift:vv,preventDefault:!0},{mac:"Cmd-ArrowDown",run:Cv,shift:Tv},{mac:"Ctrl-ArrowDown",run:Ph,shift:Av},{key:"PageUp",run:hv,shift:Sv},{key:"PageDown",run:Ph,shift:Av},{key:"Home",run:nO,shift:pO,preventDefault:!0},{key:"Mod-Home",run:kv,shift:Nv},{key:"End",run:tO,shift:hO,preventDefault:!0},{key:"Mod-End",run:Cv,shift:Tv},{key:"Enter",run:Lv,shift:Lv},{key:"Mod-a",run:xO},{key:"Backspace",run:Yh,shift:Yh,preventDefault:!0},{key:"Delete",run:Ov,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:Rv,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:CO,preventDefault:!0},{mac:"Mod-Backspace",run:TO,preventDefault:!0},{mac:"Mod-Delete",run:jO,preventDefault:!0}].concat(HO.map(t=>({mac:t.key,run:t.run,shift:t.shift}))),Iv=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:ZE,shift:dO},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:eO,shift:fO},{key:"Alt-ArrowUp",run:MO},{key:"Shift-Alt-ArrowUp",run:DO},{key:"Alt-ArrowDown",run:RO},{key:"Shift-Alt-ArrowDown",run:_O},{key:"Mod-Alt-ArrowUp",run:SO},{key:"Mod-Alt-ArrowDown",run:AO},{key:"Escape",run:kO},{key:"Mod-Enter",run:BO},{key:"Alt-l",mac:"Ctrl-l",run:vO},{key:"Mod-i",run:wO,preventDefault:!0},{key:"Mod-[",run:$v},{key:"Mod-]",run:Bv},{key:"Mod-Alt-\\",run:$O},{key:"Shift-Mod-k",run:LO},{key:"Shift-Mod-\\",run:oO},{key:"Mod-/",run:RE},{key:"Alt-A",mac:"Ctrl-A",run:_E},{key:"Ctrl-m",mac:"Shift-Alt-m",run:IO}].concat(zO),UO={key:"Tab",run:Bv,shift:$v};function Hv({ariaLabel:t,dataTestId:e,ariaControls:n,ariaActiveDescendant:r,ariaAutocomplete:s,ariaExpanded:a}){const c={"aria-label":t,"aria-multiline":"true",role:"textbox",spellcheck:"false"};return e&&(c["data-testid"]=e),n&&(c["aria-controls"]=n),r&&(c["aria-activedescendant"]=r),s&&(c["aria-autocomplete"]=s),a!==void 0&&(c["aria-expanded"]=String(a)),c}function zv(t){const e=t==="dark";return Xe.theme({"&":{height:"100%",backgroundColor:e?"#030712":"#ffffff",color:e?"#f3f4f6":"#111827"},"&.cm-focused":{outline:"none"},".cm-scroller":{fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"12px",lineHeight:"24px",overflow:"auto"},".cm-content":{minHeight:"100%",padding:"8px 12px",caretColor:e?"#f9fafb":"#111827"},".cm-line":{padding:"0"},".cm-cursor, .cm-dropCursor":{borderLeftColor:e?"#f9fafb":"#111827"},".cm-gutters":{backgroundColor:e?"#111827":"#f9fafb",color:e?"#6b7280":"#9ca3af",borderRight:`1px solid ${e?"#1f2937":"#e5e7eb"}`},".cm-activeLine":{backgroundColor:e?"#11182780":"#f3f4f680"},".cm-activeLineGutter":{backgroundColor:e?"#1f2937":"#f3f4f6"},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:e?"#1d4ed880":"#bfdbfe"}},{dark:e})}const VO={key:"Enter",run:t=>(t.dispatch(t.state.replaceSelection(` +`)),!0)};function Uv(t){const e=Iv.filter(n=>n.key!=="Enter");return vx.of(t?[...Iv,...iv,UO]:[VO,...e,...iv])}const Ha=I.forwardRef(({ariaLabel:t,value:e,onChange:n,language:r="text",theme:s="light",minLines:a=7,maxLines:c=16,dataTestId:u,wrap:f=!1,autoIndent:h=!1,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w,onEditorKeyDown:A,onCursorChange:C},E)=>{const D=I.useRef(null),O=I.useRef(null),j=I.useRef(n),R=I.useRef(C),_=I.useRef(A),L=I.useRef(!1),M=I.useRef({value:e,theme:s,wrap:f,autoIndent:h,ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w}),G=I.useMemo(()=>new nr,[]),Y=I.useMemo(()=>new nr,[]),B=I.useMemo(()=>new nr,[]),K=I.useMemo(()=>new nr,[]),ee=I.useMemo(()=>new nr,[]);j.current=n,R.current=C,_.current=A,I.useImperativeHandle(E,()=>({focus:()=>O.current?.focus(),getSelection:()=>{const J=O.current?.state.selection.main;return J?{from:J.from,to:J.to}:{from:0,to:0}},setSelection:(J,oe=J)=>{const he=O.current;if(!he)return;const Se=he.state.doc.length,T=Math.max(0,Math.min(J,Se)),z=Math.max(0,Math.min(oe,Se));he.dispatch({selection:{anchor:T,head:z},scrollIntoView:!0}),he.focus(),R.current?.(T)},coordsAtPos:J=>{const oe=O.current;if(!oe)return null;const he=Math.max(0,Math.min(J,oe.state.doc.length)),Se=oe.coordsAtPos(he);return Se?{left:Se.left,right:Se.right,top:Se.top,bottom:Se.bottom}:null}}),[]),I.useEffect(()=>{if(!D.current||O.current)return;const J=M.current,oe=St.create({doc:J.value,extensions:[zE(),Dj(),G.of(zv(J.theme)),Y.of(J.wrap?Xe.lineWrapping:[]),B.of(J.wrap?[]:[Rx(),_x(),Tx()]),K.of(Uv(J.autoIndent)),ee.of(Xe.contentAttributes.of(Hv(J))),Jo.highest(Xe.domEventHandlers({keydown:Se=>(_.current?.(Se),Se.defaultPrevented)})),Xe.updateListener.of(Se=>{Se.docChanged&&!L.current&&j.current(Se.state.doc.toString()),(Se.selectionSet||Se.docChanged)&&R.current?.(Se.state.selection.main.head)})]}),he=new Xe({state:oe,parent:D.current});return O.current=he,()=>{he.destroy(),O.current=null}},[ee,B,K,G,Y]),I.useEffect(()=>{const J=O.current;if(!J||J.state.doc.toString()===e)return;const oe=J.state.selection.main;L.current=!0,J.dispatch({changes:{from:0,to:J.state.doc.length,insert:e},selection:{anchor:Math.min(oe.anchor,e.length),head:Math.min(oe.head,e.length)}}),L.current=!1},[e]),I.useEffect(()=>{O.current?.dispatch({effects:G.reconfigure(zv(s))})},[s,G]),I.useEffect(()=>{O.current?.dispatch({effects:Y.reconfigure(f?Xe.lineWrapping:[])}),O.current?.dispatch({effects:B.reconfigure(f?[]:[Rx(),_x(),Tx()])})},[B,f,Y]),I.useEffect(()=>{O.current?.dispatch({effects:K.reconfigure(Uv(h))})},[h,K]),I.useEffect(()=>{O.current?.dispatch({effects:ee.reconfigure(Xe.contentAttributes.of(Hv({ariaLabel:t,dataTestId:u,ariaControls:g,ariaActiveDescendant:b,ariaAutocomplete:v,ariaExpanded:w})))})},[b,v,g,w,t,ee,u]);const be=Math.max(1,e.split(` +`).length),ge=Math.min(c,Math.max(a,be))*24+16,q=s==="dark";return p.jsx("div",{className:`api-client-code-editor min-w-0 overflow-hidden rounded-md border focus-within:ring-2 focus-within:ring-inset focus-within:ring-blue-500 ${q?"border-gray-700 bg-gray-950":"border-gray-300 bg-white"}`,"data-editor":"codemirror","data-language":r,"data-wrap":f?"soft":"off",style:{height:ge},children:p.jsx("div",{ref:D,className:"h-full min-w-0"})})});Ha.displayName="ApiClientCodeEditor";const Vv=()=>({key:"",value:"",enabled:!0}),Gh=()=>({key:"",value:"",enabled:!0,type:"text"}),Fv=[["application/json","JSON — application/json"],["application/problem+json","Problem JSON — application/problem+json"],["application/ld+json","JSON-LD — application/ld+json"],["text/plain","Text — text/plain"],["application/xml","XML — application/xml"],["text/html","HTML — text/html"],["application/javascript","JavaScript — application/javascript"],["application/octet-stream","Binary — application/octet-stream"]];function FO(t){const e=(t||"").toLowerCase();return e.includes("json")?"json":e.includes("xml")?"xml":e.includes("html")?"html":e.includes("javascript")?"javascript":"text"}function PO({label:t,entries:e,onChange:n,inputClass:r}){const s=(a,c)=>n(e.map((u,f)=>f===a?{...u,...c}:u));return p.jsxs("div",{className:"space-y-2",children:[e.map((a,c)=>p.jsxs("div",{className:"grid grid-cols-[auto_1fr_1fr_auto] items-center gap-2",children:[p.jsx("input",{"aria-label":`${t} ${c+1} enabled`,type:"checkbox",checked:a.enabled!==!1,onChange:u=>s(c,{enabled:u.target.checked})}),p.jsx("input",{"aria-label":`${t} ${c+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Key",value:a.key,onChange:u=>s(c,{key:u.target.value})}),p.jsx("input",{"aria-label":`${t} ${c+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${r}`,placeholder:"Value",value:a.value,onChange:u=>s(c,{value:u.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${t.toLowerCase()} ${c+1}`,className:"rounded-md border p-2",onClick:()=>n(e.filter((u,f)=>f!==c)),children:p.jsx(fi,{className:"h-4 w-4"})})]},c)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>n([...e,Vv()]),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add field"]})]})}const YO=({draft:t,onChange:e,theme:n="light"})=>{const r=t.bodyMode||ha(t),s=n==="dark",a=s?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",u=Fv.some(([v])=>v===t.contentType)?t.contentType||"application/json":"__custom__",f=I.useMemo(()=>{if(r!=="json"||!(t.body||"").trim())return null;try{return JSON.parse(t.body||""),""}catch(v){return v instanceof Error?v.message:"Invalid JSON"}},[t.body,r]),h=I.useMemo(()=>{const v=t.graphql?.variables?.trim();if(r!=="graphql"||!v)return null;try{return JSON.parse(v),""}catch(w){return w instanceof Error?w.message:"Invalid JSON"}},[t.graphql?.variables,r]),g=v=>{const w={bodyMode:v};v==="json"&&(!t.contentType||!t.contentType.includes("json"))&&(w.contentType="application/json"),v==="raw"&&!t.contentType&&(w.contentType="text/plain"),v==="urlencoded"&&(w.contentType="application/x-www-form-urlencoded"),v==="formdata"&&(w.contentType=void 0),v==="binary"&&!t.contentType&&(w.contentType="application/octet-stream"),v==="graphql"&&(w.contentType="application/json"),e({...t,...w})},b=(v,w)=>{const A=t.formData||[Gh()];e({...t,formData:A.map((C,E)=>E===v?{...C,...w}:C)})};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-body-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Body type",p.jsxs("select",{"aria-label":"Request body type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:r,onChange:v=>g(v.target.value),children:[p.jsx("option",{value:"none",children:"None"}),p.jsx("option",{value:"json",children:"JSON"}),p.jsx("option",{value:"raw",children:"Raw"}),p.jsx("option",{value:"urlencoded",children:"x-www-form-urlencoded"}),p.jsx("option",{value:"formdata",children:"form-data"}),p.jsx("option",{value:"binary",children:"Binary"}),p.jsx("option",{value:"graphql",children:"GraphQL"})]})]}),(r==="json"||r==="raw"||r==="binary")&&p.jsxs("div",{className:"flex flex-wrap items-end gap-2",children:[p.jsxs("label",{className:"text-sm font-medium",children:["Content type",p.jsxs("select",{"aria-label":"Content type",className:`ml-2 rounded-md border px-3 py-2 text-sm ${a}`,value:u,onChange:v=>{const w=v.target.value==="__custom__"?"":v.target.value;e({...t,contentType:w})},children:[Fv.map(([v,w])=>p.jsx("option",{value:v,children:w},v)),p.jsx("option",{value:"__custom__",children:"Custom…"})]})]}),u==="__custom__"&&p.jsx("input",{"aria-label":"Custom content type",className:`rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"application/vnd.example+json",value:t.contentType||"",onChange:v=>e({...t,contentType:v.target.value})})]})]}),r==="none"&&p.jsx("div",{className:`rounded-md border border-dashed p-4 text-sm ${s?"border-gray-700 text-gray-400":"border-gray-300 text-gray-500"}`,children:"This request has no body."}),(r==="json"||r==="raw")&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(Ha,{ariaLabel:"Request body",language:r==="json"?"json":FO(t.contentType),theme:n,value:t.body||"",onChange:v=>e({...t,body:v}),minLines:9,maxLines:20}),p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${f?"text-red-600":r==="json"&&f===""?"text-green-600":s?"text-gray-400":"text-gray-500"}`,children:r==="json"?f?`Invalid JSON: ${f}`:(t.body||"").trim()?"Valid JSON":"Enter a JSON object, array, or value.":"Raw body is sent exactly as entered."}),r==="json"&&p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!!f||!(t.body||"").trim(),onClick:()=>{try{e({...t,body:JSON.stringify(JSON.parse(t.body||""),null,2)})}catch{}},children:"Beautify JSON"})]})]}),r==="urlencoded"&&p.jsxs("div",{className:"space-y-2",children:[p.jsx(PO,{label:"Form field",entries:t.urlencoded?.length?t.urlencoded:[Vv()],inputClass:a,onChange:v=>e({...t,urlencoded:v,contentType:"application/x-www-form-urlencoded"})}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"Enabled fields are URL-encoded at send time. Variable substitution still applies to keys and values."})]}),r==="formdata"&&p.jsxs("div",{className:"space-y-2",children:[(t.formData?.length?t.formData:[Gh()]).map((v,w)=>p.jsxs("div",{className:"grid gap-2 md:grid-cols-[auto_7rem_1fr_1fr_auto]",children:[p.jsx("input",{"aria-label":`Form data ${w+1} enabled`,type:"checkbox",checked:v.enabled!==!1,onChange:A=>b(w,{enabled:A.target.checked})}),p.jsxs("select",{"aria-label":`Form data ${w+1} type`,className:`rounded-md border px-2 py-2 text-sm ${a}`,value:v.type||"text",onChange:A=>b(w,{type:A.target.value,file:void 0,fileName:void 0}),children:[p.jsx("option",{value:"text",children:"Text"}),p.jsx("option",{value:"file",children:"File"})]}),p.jsx("input",{"aria-label":`Form data ${w+1} key`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Key",value:v.key,onChange:A=>b(w,{key:A.target.value})}),v.type==="file"?p.jsxs("label",{className:`flex min-w-0 cursor-pointer items-center rounded-md border px-3 py-2 text-sm ${a}`,children:[p.jsx("span",{className:"truncate",children:v.file?.name||v.fileName||"Choose file…"}),p.jsx("input",{"aria-label":`Form data ${w+1} file`,className:"sr-only",type:"file",onChange:A=>{const C=A.target.files?.[0];b(w,{file:C,fileName:C?.name,contentType:C?.type||void 0})}})]}):p.jsx("input",{"aria-label":`Form data ${w+1} value`,className:`min-w-0 rounded-md border px-3 py-2 text-sm ${a}`,placeholder:"Value",value:v.value,onChange:A=>b(w,{value:A.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove form data ${w+1}`,className:"rounded-md border p-2",onClick:()=>e({...t,formData:(t.formData||[]).filter((A,C)=>C!==w)}),children:p.jsx(fi,{className:"h-4 w-4"})})]},w)),p.jsxs("button",{type:"button",className:"inline-flex items-center gap-2 rounded-md border px-3 py-2 text-xs",onClick:()=>e({...t,formData:[...t.formData||[],Gh()]}),children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add form-data field"]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The browser supplies the multipart boundary automatically. Imported Postman file paths must be re-selected from this browser."})]}),r==="binary"&&p.jsxs("div",{className:"space-y-2",children:[p.jsxs("label",{className:`flex cursor-pointer items-center justify-between gap-3 rounded-md border px-3 py-3 text-sm ${a}`,children:[p.jsx("span",{className:"min-w-0 truncate",children:t.binary?.file?.name||t.binary?.fileName||"Choose binary file…"}),p.jsx("span",{className:"shrink-0 text-xs font-medium",children:"Browse"}),p.jsx("input",{"aria-label":"Binary file",className:"sr-only",type:"file",onChange:v=>{const w=v.target.files?.[0];e({...t,contentType:w?.type||t.contentType||"application/octet-stream",binary:{file:w,fileName:w?.name||t.binary?.fileName,contentType:w?.type||t.binary?.contentType}})}})]}),p.jsx("p",{className:`text-xs ${s?"text-gray-400":"text-gray-500"}`,children:"The selected file is sent as the request body without text conversion. Saved requests retain only file metadata, so the browser asks you to re-select the file before a later send or collection run."})]}),r==="graphql"&&p.jsxs("div",{className:"grid gap-3 xl:grid-cols-2",children:[p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Query"}),p.jsx(Ha,{ariaLabel:"GraphQL query",language:"graphql",theme:n,value:t.graphql?.query||"",onChange:v=>e({...t,graphql:{query:v,variables:t.graphql?.variables||""}}),minLines:9,maxLines:20})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("div",{className:"text-xs font-medium",children:"Variables (JSON)"}),p.jsx(Ha,{ariaLabel:"GraphQL variables",language:"json",theme:n,value:t.graphql?.variables||"",onChange:v=>e({...t,graphql:{query:t.graphql?.query||"",variables:v}}),minLines:9,maxLines:20}),p.jsx("div",{className:`text-xs ${h?"text-red-600":s?"text-gray-400":"text-gray-500"}`,children:h?`Invalid variables JSON: ${h}`:"Variables are serialized with the query as application/json."})]})]})]})};function KO(t,e){return t.find(([n])=>n.toLowerCase()===e.toLowerCase())?.[1]||""}function GO(t,e){const n=e.toLowerCase();if(n.includes("json"))try{return{body:JSON.stringify(JSON.parse(t),null,2),language:"json"}}catch{return{body:t,language:"json",invalidJson:!0}}return n.includes("html")?{body:t,language:"markup"}:n.includes("xml")?{body:t,language:"markup"}:n.includes("javascript")?{body:t,language:"javascript"}:{body:t,language:"text"}}function XO(t,e){const n=e.trim().toLowerCase();if(!n)return 0;let r=0,s=0;const a=t.toLowerCase();for(;ss.toLowerCase().includes(n)).join(` -`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),O=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),E=e==="dark",j=r?s:"pretty",M=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(M,c),[c,M]),q=I.useMemo(()=>f?JO(M,c):M,[c,M,f]),R=g.trim().toLowerCase(),J=t.headers.filter(([W,ye])=>!R||`${W}: ${ye}`.toLowerCase().includes(R)),U=E?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=E?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?E?"text-red-300":"text-red-600":E?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${E?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(W=>{const ye=W==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":ye,"aria-pressed":s===W,className:`px-3 py-1.5 text-xs font-medium ${s===W?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(W),children:ye},W)}),p.jsx("button",{type:"button",disabled:!O,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":E?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${U}`,placeholder:"Search response body…",value:c,onChange:W=>u(W.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:W=>h(W.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${E?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:q||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:q||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&O&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${E?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${E?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${U}`,placeholder:"Filter headers…",value:g,onChange:W=>b(W.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:E?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[J.map(([W,ye],me)=>p.jsxs("tr",{className:E?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:W}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:ye})]},`${W}:${me}`)),J.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { +`):t}const QO=({response:t,theme:e="light",curlCommand:n,advanced:r=!0})=>{const[s,a]=I.useState("pretty"),[c,u]=I.useState(""),[f,h]=I.useState(!1),[g,b]=I.useState(""),[v,w]=I.useState(!1),A=KO(t.headers,"content-type"),C=I.useMemo(()=>GO(t.body,A),[A,t.body]),E=/(?:text\/html|application\/xhtml\+xml)/i.test(A),D=I.useMemo(()=>new TextEncoder().encode(t.body).byteLength,[t.body]),O=e==="dark",j=r?s:"pretty",R=j==="pretty"?C.body:t.body,_=I.useMemo(()=>XO(R,c),[c,R]),L=I.useMemo(()=>f?JO(R,c):R,[c,R,f]),M=g.trim().toLowerCase(),G=t.headers.filter(([ee,be])=>!M||`${ee}: ${be}`.toLowerCase().includes(M)),Y=O?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",B=O?"text-gray-400":"text-gray-500",K=async()=>{if(!(!n||typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(n),w(!0),window.setTimeout(()=>w(!1),1500)}catch{w(!1)}};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-response-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[p.jsxs("div",{id:"api-client-response-heading",className:"font-semibold",children:["Response ",p.jsxs("span",{className:t.status>=400?O?"text-red-300":"text-red-600":O?"text-green-300":"text-green-600",children:[t.status," ",t.statusText]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsxs("div",{className:`flex flex-wrap gap-3 text-xs ${B}`,children:[t.transport&&p.jsx("span",{"aria-label":"Actual transport",children:t.transport==="api-host"?"API host":"Browser"}),t.transport==="api-host"&&t.hostRoundTripTime!=null?p.jsxs(p.Fragment,{children:[p.jsxs("span",{children:["Host ",Math.max(0,t.hostRoundTripTime-t.responseTime)," ms"]}),p.jsxs("span",{children:["Target ",t.responseTime," ms"]})]}):p.jsxs("span",{children:[t.responseTime," ms"]}),p.jsxs("span",{children:[D.toLocaleString()," B"]}),A&&p.jsx("span",{className:"font-mono",children:A.split(";")[0]})]}),n&&p.jsx("button",{type:"button",className:`rounded-md border px-2.5 py-1.5 text-xs font-medium ${O?"border-gray-700 bg-gray-900 text-gray-200 hover:bg-gray-800":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"}`,onClick:()=>{K()},"aria-label":"Copy request as cURL",children:v?"Copied cURL":"Copy as cURL"})]})]}),r&&p.jsxs("div",{className:`flex w-fit overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-300"}`,role:"group","aria-label":"Response body view",children:[["pretty","raw"].map(ee=>{const be=ee==="pretty"?"Pretty":"Raw";return p.jsx("button",{type:"button","aria-label":be,"aria-pressed":s===ee,className:`px-3 py-1.5 text-xs font-medium ${s===ee?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"}`,onClick:()=>a(ee),children:be},ee)}),p.jsx("button",{type:"button",disabled:!E,"aria-pressed":s==="preview",className:`px-3 py-1.5 text-xs font-medium ${s==="preview"?"bg-blue-600 text-white":O?"bg-gray-900 text-gray-300":"bg-white text-gray-700"} disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>a("preview"),children:"Preview"})]}),r&&j!=="preview"&&p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[p.jsx("input",{"aria-label":"Search response body",type:"search",className:`min-w-0 flex-1 rounded-md border px-3 py-2 text-sm ${Y}`,placeholder:"Search response body…",value:c,onChange:ee=>u(ee.target.value)}),p.jsx("span",{className:`text-xs ${B}`,children:c.trim()?`${_} match${_===1?"":"es"}`:"Search exact response text"}),p.jsxs("label",{className:`inline-flex items-center gap-2 text-xs ${B}`,children:[p.jsx("input",{type:"checkbox",checked:f,disabled:!c.trim(),onChange:ee=>h(ee.target.checked)}),"Only matching lines"]})]}),j==="pretty"&&p.jsxs("div",{className:"space-y-2",children:[C.invalidJson&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${O?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:"Response declares JSON but could not be parsed. Showing the exact payload."}),p.jsx(Rr,{code:L||"(empty response)",language:C.language,title:r?"Body — Pretty":"Response body",theme:e,wrap:!0})]}),r&&j==="raw"&&p.jsx("div",{"data-testid":"api-client-response-raw-body",children:p.jsx(Rr,{code:L||"(empty response)",language:"text",title:"Body — Raw",theme:e,wrap:!0})}),r&&j==="preview"&&E&&p.jsx("iframe",{title:"Response preview",sandbox:"",srcDoc:t.body,className:`min-h-80 w-full rounded-md border bg-white ${O?"border-gray-700":"border-gray-300"}`}),r&&t.headers.length>0&&p.jsxs("section",{className:`overflow-hidden rounded-md border ${O?"border-gray-700":"border-gray-200"}`,"aria-labelledby":"api-client-response-headers-heading",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-3 py-2",children:[p.jsxs("h4",{id:"api-client-response-headers-heading",className:"text-sm font-medium",children:["Response headers (",t.headers.length,")"]}),p.jsx("input",{"aria-label":"Filter response headers",type:"search",className:`rounded-md border px-2 py-1.5 text-xs ${Y}`,placeholder:"Filter headers…",value:g,onChange:ee=>b(ee.target.value)})]}),p.jsx("div",{className:"overflow-x-auto border-t",children:p.jsxs("table",{className:"w-full min-w-[28rem] text-left text-xs",children:[p.jsx("thead",{className:O?"bg-gray-900 text-gray-300":"bg-gray-50 text-gray-600",children:p.jsxs("tr",{children:[p.jsx("th",{className:"px-3 py-2 font-medium",children:"Header"}),p.jsx("th",{className:"px-3 py-2 font-medium",children:"Value"})]})}),p.jsxs("tbody",{children:[G.map(([ee,be],ce)=>p.jsxs("tr",{className:O?"border-t border-gray-800":"border-t border-gray-100",children:[p.jsx("th",{scope:"row",className:"whitespace-nowrap px-3 py-2 font-mono font-medium",children:ee}),p.jsx("td",{className:"break-all px-3 py-2 font-mono",children:be})]},`${ee}:${ce}`)),G.length===0&&p.jsx("tr",{children:p.jsx("td",{colSpan:2,className:`px-3 py-4 text-center ${B}`,children:"No response headers match this filter."})})]})]})})]})]})};function WO(t){if(!t.trim())return{valid:!0,message:"Ready"};try{return new Function("flex","console",`"use strict"; return (async () => { ${t} });`),{valid:!0,message:"Syntax OK"}}catch(e){return{valid:!1,message:e instanceof Error?e.message:String(e)}}}function ZO(t,e){let n=0,r=0;const s={...e};for(let a=0;aO+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` -`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),O=I.useMemo(()=>WO(e),[e]),D=s==="dark",E=B=>{const K=u.current,W=c.current;if(!K||!W)return;const ye=K.coordsAtPos(B);if(!ye)return;const me=W.getBoundingClientRect(),fe=ye.left-me.left,L=Math.max(8,me.width-430),Q=ye.bottom-me.top+2,oe=Math.max(8,me.height-96);A({left:Math.max(8,Math.min(fe,L)),top:Math.max(8,Math.min(Q,oe))})},j=(B,K,W=!1)=>{const ye=o3(B,K,r,a,W);g(ye),v(0),ye&&requestAnimationFrame(()=>E(K))},M=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,W=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(W)})},_=()=>{if(!O.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const q=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(W=>(W+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(W=>(W-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),M(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},R=h?.items[b],J=!!h&&h.items.length>0,U=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:O.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${O.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[O.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:O.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!O.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:J?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:J?C:void 0,ariaExpanded:J,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const W=u.current?.getSelection().from??K;j(B,W)})},onCursorChange:B=>{h&&E(B)},onEditorKeyDown:q,theme:s,value:e,wrap:!0}),J&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${U}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:W=>{f.current[K]=W},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:W=>{W.preventDefault(),M(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),R&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[R.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:R.signature}),p.jsx("div",{children:R.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json -X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:O,variables:D={},collectionVariables:E={},externalVariables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,serverOptions:R=[],initialServerUrl:J,onServerUrlChange:U,hostExecution:B,credentialStorage:K,onCredentialStorageChange:W})=>{const ye=y3(t),me=Sn(e),fe=R.map(re=>({server:re,url:d3(re)})),L=fe.map(re=>re.url),Q=J||L.find(re=>Jv(ye.url,re))||"",oe=L.includes(Q)?Q:L[0]||"",ue=Q&&!L.includes(Q)?Q:"",ve=Q||oe||x3(ye.url),[T,z]=I.useState(ye),[he,ne]=I.useState(me),[ke,_e]=I.useState(oe),[$e,Pe]=I.useState(ue),Ke=I.useRef(ve),Ie=I.useRef(ve),[ut,Rt]=I.useState(null),[Ce,Ee]=I.useState(),[G,Se]=I.useState(null),[Ne,Re]=I.useState(null),[Ge,st]=I.useState([]),[Et,ti]=I.useState([]),[Tn,ht]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),St=I.useRef(0),x=I.useRef(h),V=I.useRef(g),pe=I.useRef(b),ae=I.useRef(null),[X,k]=I.useState(n),[F,Z]=I.useState(()=>r||(me.tests.trim()&&!me.preRequest.trim()?"tests":"pre-request")),xe=I.useRef({}),P=I.useRef({}),ce=I.useId().replace(/:/g,""),le=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{V.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{V.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(he))},[he]),I.useEffect(()=>{try{const re=O?{...T,auth:O(T.auth)}:T,Le=G0(re,{variables:D}),We=JSON.stringify([Le.method,Le.url,Le.headerEntries,Le.body,Le.bodyKind]);if(We===ae.current)return;ae.current=We,x.current?.(Le)}catch{}},[T,O,D]);const we=(T.method||"GET").toUpperCase(),Oe=["GET","HEAD"].includes(we),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Be=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(he.preRequest.trim()||he.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(re=>a==="advanced"||re.id!=="scripts"),$t=re=>`${ce}-request-tab-${re}`,Bn=re=>`${ce}-request-panel-${re}`,ii=re=>`${le}-script-tab-${re}`,En=re=>`${le}-script-panel-${re}`,_t=w3(T.url,D),Yt=re=>{re==="scripts"&&a!=="advanced"||(k(re),v?.(re))},Pn=re=>{Z(re),w?.(re)},Jr=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,We.indexOf(Le)),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Yt(Jt),xe.current[Jt]?.focus()},kl=(re,Le)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(re.key))return;re.preventDefault();const We=["pre-request","tests"],ri=We.indexOf(Le),Jt=re.key==="Home"?We[0]:re.key==="End"?We[We.length-1]:re.key==="ArrowRight"?We[(ri+1)%We.length]:We[(ri-1+We.length)%We.length];Pn(Jt),P.current[Jt]?.focus()},Li=re=>{if(!re)return;const Le=Ke.current;Ke.current=re,U?.(re),z(We=>({...We,url:f3(We.url,Le,re)}))},Fa=O?O(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${we} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${we} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=re=>B?.available===!0&&(B.capabilities||[]).includes(re),ru=re=>{if(!W||re===(K||"remember"))return;W(re),z(We=>h3(We));const Le=St.current+1;St.current=Le,m3(B).then(We=>{St.current===Le&&Vn(We)})},Nl=eN(ut,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const re=new AbortController;qn.current=re,A?.(),ht(!0),Se(null),Re(null),st([]),ti([]),Rt(null),Ee(void 0);try{const Le=await by({request:T,scripts:he,credentials:u,requestInterceptor:f,resolveAuth:O,variables:D,collectionVariables:E,externalVariables:j,environmentVariables:M,hostExecution:B,signal:re.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:q});if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}let We=Le.error||null;if(We&&Le.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,re.signal);if(re.signal.aborted){Se(c?.requestCancelled||"Request cancelled.");return}Jt&&(We=`${We} ${Jt}`)}const ri=WC(Le,T,B);We&&ri&&(We=`${We} ${ri}`),Se(We),Re(Le.scriptError||null),st(Le.scriptTests),ti(Le.scriptLogs),Le.response&&(Ee(Le.curlCommand),Rt(Le.response)),Le.result&&C?.(Le.result)}finally{qn.current===re&&(qn.current=null),ht(!1)}},Zr=()=>qn.current?.abort(),hp=Ge.filter(re=>re.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:re=>{(re.ctrlKey||re.metaKey)&&re.key==="Enter"&&Pa&&(re.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[R.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:ke,onChange:re=>{_e(re.target.value),Pe(""),Li(re.target.value)},children:fe.map(({server:re,url:Le})=>p.jsxs("option",{value:Le,children:[re.description?`${re.description} — `:"",re.url]},`${re.url}:${Le}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:$e,onChange:re=>{const Le=re.target.value;Pe(Le);const We=ke||Ie.current;(Le.trim()||We)&&Li(Le.trim()||We)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:we,onChange:re=>{const Le=re.target.value;z(We=>({...We,method:Le}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(re=>p.jsx("option",{children:re},re))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:re=>{const Le=re.target.value;z(We=>({...We,url:Le}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(re=>p.jsxs("button",{ref:Le=>{xe.current[re.id]=Le},id:$t(re.id),type:"button",role:"tab","aria-controls":Bn(re.id),"aria-label":re.label,"aria-selected":Dt===re.id,tabIndex:Dt===re.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===re.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(re.id),onKeyDown:Le=>Jr(Le,re.id),children:[p.jsx("span",{children:re.label}),re.count!==void 0&&re.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===re.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:re.count}),re.active&&re.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===re.id?"bg-white":"bg-blue-500"}`})]},re.id))})}),Oe&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${we} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:re=>z(Le=>({...Le,query:re})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:re=>z(Le=>({...Le,headers:re})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!O,advanced:a==="advanced",hostExecution:B,onChange:re=>z(Le=>({...Le,auth:re})),theme:s}),W&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Be,value:K||"remember",onChange:re=>ru(re.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},certificateId:re.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(re=>p.jsx("option",{value:re.id,children:re.name},re.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:re=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},cookieJar:re.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(re=>p.jsxs("button",{ref:Le=>{P.current[re]=Le},id:ii(re),type:"button",role:"tab","aria-controls":En(re),"aria-selected":F===re,tabIndex:F===re?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${F===re?"bg-blue-600 text-white":""}`,onClick:()=>Pn(re),onKeyDown:Le=>kl(Le,re),children:[re==="pre-request"?"Pre-request":"Tests",(re==="pre-request"?he.preRequest:he.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${F===re?"bg-white":"bg-blue-500"}`})]},re))}),F==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:he.preRequest,onChange:re=>ne(Le=>({...Le,preRequest:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:he.tests,onChange:re=>ne(Le=>({...Le,tests:re})),variableKeys:{environment:Object.keys(M),collection:Object.keys(E),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:re}})=>z(Le=>({...Le,hostExecution:{...Le.hostExecution||{},preferHostExecution:re==="inherit"?void 0:re==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),G&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),G]}),Ne&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Ne]}),ut&&p.jsx(QO,{response:ut,theme:s,curlCommand:Ce,advanced:a==="advanced"}),Ge.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",Ge.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:Ge.map((re,Le)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${re.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[re.passed?"PASS":"FAIL"," — ",re.name]}),re.error&&p.jsx("div",{className:"mt-1 text-xs",children:re.error})]},`${re.name}:${Le}`))})]}),Et.length>0&&p.jsx(Rr,{code:Et.join(` -`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,O]=I.useState(()=>S3(a,c)),[D,E]=I.useState(w.request),[j,M]=I.useState(w.serverUrl),[_,q]=I.useState(A),[R,J]=I.useState(a||"params"),[U,B]=I.useState(c||"pre-request"),[K,W]=I.useState(()=>nl()),[ye,me]=I.useState(v===!1),fe=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(ke=>{ne||(W(ke),me(!0))}).catch(()=>{ne||me(!0)}),()=>{ne=!0}},[v]);const L=my(v,K,ye),Q=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),ue=C==="advanced",ve=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{O(ne),Qh("density",ne==="advanced"?"advanced":void 0)},he=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:R,scriptTab:U});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[L&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${ve}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!ue,className:`rounded px-3 py-1.5 text-sm ${ue?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:fe?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":ue,className:`rounded px-3 py-1.5 text-sm ${ue?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:fe?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[ue&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:fe?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:he,children:[p.jsx(Nd,{className:"h-4 w-4"}),fe?.openApiClient||"Open in API Client"]})]})]}),ue&&p.jsx("div",{className:`rounded-lg border p-3 ${ve}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:fe?.environment||"Environment"}),p.jsxs("select",{"aria-label":fe?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>W(ke=>({...ke,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:fe?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:R,initialScriptTab:U,density:C,theme:r,messages:fe,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>W(ke=>({...ke,credentialStorage:ne})),environmentVariables:Q,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:M,onRequestChange:u,onDraftChange:E,onScriptsChange:ne=>q(Sn(ne)),onRequestTabChange:ne=>{J(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>W(ke=>hf(ke,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,O]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,E]=I.useState(!1),j=I.useId().replace(/:/g,""),M=I.useRef({}),_=I.useMemo(()=>B0(t,e,n,q0(t,e,n)),[t,e,n]),[q,R]=I.useState(_),U=t.paths[e]?.[n.toLowerCase()],B=I.useMemo(()=>Rk(t,e,n),[t,e,n]),K=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!U)return p.jsx("div",{className:"p-6",children:"Operation not found."});const W=r==="dark"?"text-gray-400":"text-gray-600",ye=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",me=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",fe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,L=U.security??t.security,Q={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},oe=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",ue=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",ve=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",T=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",z=Ce=>`${j}-code-tab-${Ce}`,he=`${j}-code-panel`,ne=Ce=>{const Ee=!A.has(Ce);w(G=>{const Se=new Set(G.key===b?G.sections:g);return Se.has(Ce)?Se.delete(Ce):Se.add(Ce),{key:b,sections:Se}}),Ce==="tryIt"&&T3("tryIt",Ee?"1":void 0)},ke=(Ce,Ee,G)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${Ee}-heading`,children:[p.jsxs("button",{type:"button",id:`${Ee}-heading`,"aria-expanded":A.has(Ee),onClick:()=>ne(Ee),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(Ee)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),Ce]}),A.has(Ee)&&G]}),_e=Ce=>{O(Ce),M.current[Ce]?.focus()},$e=(Ce,Ee)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(Ce.key))return;Ce.preventDefault();const G=fe.indexOf(Ee),Se=Ce.key==="Home"?fe[0]:Ce.key==="End"?fe[fe.length-1]:Ce.key==="ArrowRight"?fe[(G+1)%fe.length]:fe[(G-1+fe.length)%fe.length];_e(Se)},Pe=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const Ce=new URL(window.location.href);Ce.hash=Wh(e,n),await navigator.clipboard.writeText(Ce.toString()),E(!0),window.setTimeout(()=>E(!1),1400)},Ke=U.requestBody?In.isReference(U.requestBody)?In.resolveReference(t,U.requestBody.$ref):U.requestBody:void 0,Ie=Object.entries(U).filter(([Ce])=>Ce.startsWith("x-")),ut=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Rt=c?.routes.some(Ce=>Ce.method===n.toUpperCase()&&Ce.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${me}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:ut?.bg,borderColor:ut?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{Pe()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),U.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:U.summary}),U.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${W}`,children:U.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[U.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),L?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Rt?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":W,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),U.operationId&&p.jsxs("span",{className:W,children:["operationId: ",p.jsx("code",{children:U.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&Ie.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${ye}`,children:Ie.map(([Ce,Ee])=>p.jsxs("div",{children:[p.jsx("code",{children:Ce}),": ",typeof Ee=="string"?Ee:JSON.stringify(Ee)]},Ce))})]}),B.length>0&&ke(K?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:B.map(Ce=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:Ce.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${oe}`,children:Ce.in}),Ce.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"}),Ce.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ve}`,children:"deprecated"})]}),Ce.description&&p.jsx("p",{className:`mb-3 text-sm ${W}`,children:Ce.description}),Ce.schema&&p.jsx(Dr,{spec:t,schema:Ce.schema,theme:r,required:Ce.required,...Q})]},`${Ce.in}:${Ce.name}`))})),Ke&&ke(K?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[Ke.description&&p.jsx("p",{className:W,children:Ke.description}),Object.entries(Ke.content||{}).map(([Ce,Ee])=>p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${T}`,children:Ce}),Ke.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${ue}`,children:"required"})]}),Ee.schema&&p.jsx(Dr,{spec:t,schema:Ee.schema,theme:r,...Q}),Ee.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ee.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},Ce))]})),ke(K?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(U.responses||{}).map(([Ce,Ee])=>{const G=In.isReference(Ee)?In.resolveReference(t,Ee.$ref):Ee;return p.jsxs("div",{className:`rounded-lg border p-4 ${ye}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:Ce}),p.jsx("span",{className:`text-sm ${W}`,children:G.description})]}),G.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(G.headers).join(", ")]}),G.content&&Object.entries(G.content).map(([Se,Ne])=>{const Re=Ne.examples&&Object.values(Ne.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${T}`,children:Se}),Ne.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:Ne.schema,theme:r,...Q})}),Ne.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Ne.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),Re&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(Re.value??Re,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},Se)})]},Ce)})})),s.tryIt?.enabled!==!1&&ke(K?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:R,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&ke(K?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:fe.map(Ce=>p.jsx("button",{ref:Ee=>{M.current[Ce]=Ee},id:z(Ce),type:"button",role:"tab","aria-controls":he,"aria-selected":C===Ce,tabIndex:C===Ce?0:-1,onClick:()=>_e(Ce),onKeyDown:Ee=>$e(Ee,Ce),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===Ce?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(Ce)},Ce))}),p.jsx("div",{role:"tabpanel",id:he,"aria-labelledby":z(C),children:p.jsx(Rr,{code:Lk(q,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),U.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:U.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:U.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),O=I.useRef(null),D=I.useRef([]),E=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(ye=>!ye.closest(".hidden")),j=I.useMemo(()=>{const ye=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&E?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[me,fe]of Object.entries(t.paths))for(const L of In.getHttpMethods(fe))ye.push({id:`operation:${L}:${me}`,label:`${L.toUpperCase()} ${me}`,action:()=>n(me,L)});return ye},[E,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),M=b.trim().toLowerCase(),_=I.useMemo(()=>M?j.filter(ye=>ye.label.toLowerCase().includes(M)):j,[j,M]),{start:q,end:R}=P3(_.length,w),J=_.slice(q,R),U=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(ye=>{ye&&(U(),ye.action())},[U]);if(I.useEffect(()=>{const ye=me=>{!(me.ctrlKey||me.metaKey)||me.key.toLowerCase()!=="k"||(me.preventDefault(),g(fe=>!fe))};return document.addEventListener("keydown",ye),()=>document.removeEventListener("keydown",ye)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const ye=document.activeElement instanceof HTMLElement?document.activeElement:null,me=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>O.current?.focus());const fe=L=>{if(L.key==="Escape"){L.preventDefault(),U();return}if(L.key==="ArrowDown"||L.key==="ArrowUp"||L.key==="Home"||L.key==="End"){L.preventDefault(),A(T=>!_.length||L.key==="Home"?0:L.key==="End"?_.length-1:L.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(L.key==="Enter"){L.preventDefault(),B(_[w]);return}if(L.key!=="Tab"||!C.current)return;const Q=Y3(C.current);if(!Q.length)return;const oe=Q[0],ue=Q[Q.length-1],ve=document.activeElement;L.shiftKey&&(ve===oe||!C.current.contains(ve))?(L.preventDefault(),ue.focus()):!L.shiftKey&&(ve===ue||!C.current.contains(ve))&&(L.preventDefault(),oe.focus())};return document.addEventListener("keydown",fe),()=>{document.body.style.overflow=me,document.removeEventListener("keydown",fe),ye?.isConnected&&ye.focus()}},[w,B,U,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",W=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:U}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:O,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:ye=>{v(ye.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[q>0&&p.jsx("div",{"aria-hidden":"true",style:{height:q*tp}}),J.map((ye,me)=>{const fe=q+me;return p.jsx("button",{ref:L=>{D.current[fe]=L},type:"button",role:"option","aria-selected":fe===w,"aria-posinset":fe+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${fe===w?W:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(fe),onClick:()=>B(ye),children:ye.label},ye.id)}),R<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-R)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const M=J3(b.current);if(M.length===0){j.preventDefault(),b.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!b.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!b.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",O=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const E=D.target.value;h(E==="host"?void 0:E==="custom"?[...c]:E)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O.includes(D),onChange:E=>{const j=new Set(O);E.target.checked?j.add(D):j.delete(D),h(Cs.filter(M=>j.has(M)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const O=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const E=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const M=W3(f.current);if(M.length===0){j.preventDefault(),f.current.focus();return}const _=M[0],q=M[M.length-1],R=document.activeElement;j.shiftKey&&(R===_||!f.current.contains(R))?(j.preventDefault(),q.focus()):!j.shiftKey&&(R===q||!f.current.contains(R))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",E),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",E),O?.isConnected&&O.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?O=>{O.location.method&&(c(O.location.path,O.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route"}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?O=>{c(O.path,O.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=!!(r&&f&&u.location.method),g=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return h?p.jsx("button",{type:"button","aria-label":`${n?.openRuntimeRoute||"Open documented operation"} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:g},u.id):p.jsx("div",{className:"rounded border p-2",children:g},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} -`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,E=!D&&hM(O);let j;O.result&&!D&&(s=oy(s,{...O.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:E}),j=s.history[0]?.id);const M={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:E,cancelled:D,historyEntryId:j,outcome:O};if(a.push(M),t.onRequestComplete?.(M,g,e.length),D){c=!0;break}if(!M.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,O]=I.useState(""),[D,E]=I.useState(""),[j,M]=I.useState(null),[_,q]=I.useState(""),R=h.collections.find(G=>G.id===u)||h.collections[0],J=I.useMemo(()=>h.folders.filter(G=>G.collectionId===R?.id),[R?.id,h.folders]),U=I.useMemo(()=>h.requests.filter(G=>G.collectionId===R?.id),[R?.id,h.requests]),B=J.find(G=>G.id===f),K=I.useMemo(()=>new Map(J.map(G=>[G.id,G])),[J]),W=I.useMemo(()=>{const G=[],Se=new Set,Ne=(Re,Ge)=>{J.filter(st=>st.parentFolderId===Re).forEach(st=>{Se.has(st.id)||(Se.add(st.id),G.push({folder:st,depth:Ge}),Ne(st.id,Ge+1))})};return Ne(void 0,0),J.forEach(Re=>{Se.has(Re.id)||(Se.add(Re.id),G.push({folder:Re,depth:0}),Ne(Re.id,1))}),G},[J]),ye=G=>{const Se=[],Ne=new Set;let Re=K.get(G);for(;Re&&!Ne.has(Re.id);)Ne.add(Re.id),Se.unshift(Re.name),Re=Re.parentFolderId?K.get(Re.parentFolderId):void 0;return Se.join(" / ")};I.useEffect(()=>{r?.(R?.id)},[r,R?.id]);const me=(G,Se)=>{try{const Ne=sM(h,G),Re=new Blob([uM(Ne)],{type:"application/json;charset=utf-8"}),Ge=URL.createObjectURL(Re),st=document.createElement("a");st.href=Ge,st.download=mM(Se),st.click(),setTimeout(()=>URL.revokeObjectURL(Ge),0),q("")}catch(Ne){q(Ne instanceof Error?Ne.message:String(Ne))}},fe=()=>{const G=w.trim();if(!G)return;const Se=Gr(),Ne=An("collection");g(Re=>({...Re,collections:[...Re.collections,{id:Ne,name:G,auth:{type:"none"},variables:[],createdAt:Se,updatedAt:Se}]})),r?.(Ne),s?.(""),A(""),M(null)},L=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,auth:G,updatedAt:Se}:Re)}))},Q=G=>{if(!B)return;const Se=Gr();g(Ne=>({...Ne,folders:Ne.folders.map(Re=>Re.id===B.id?{...Re,auth:G,updatedAt:Se}:Re)}))},oe=()=>{if(!R)return;const G=Gr();g(Se=>({...Se,collections:Se.collections.map(Ne=>Ne.id===R.id?{...Ne,variables:[...Ne.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:G}:Ne)}))},ue=(G,Se)=>{if(!R)return;const Ne=Gr();g(Re=>({...Re,collections:Re.collections.map(Ge=>Ge.id===R.id?{...Ge,variables:Ge.variables.map(st=>st.id===G?{...st,...Se}:st),updatedAt:Ne}:Ge)}))},ve=G=>{if(!R)return;const Se=Gr();g(Ne=>({...Ne,collections:Ne.collections.map(Re=>Re.id===R.id?{...Re,variables:Re.variables.filter(Ge=>Ge.id!==G),updatedAt:Se}:Re)}))},T=()=>{const G=C.trim();if(!G||!R)return;const Se=Gr(),Ne=An("folder");g(Re=>({...Re,folders:[...Re.folders,{id:Ne,collectionId:R.id,parentFolderId:f||void 0,name:G,auth:{type:"inherit"},createdAt:Se,updatedAt:Se}]})),s?.(Ne),O("")},z=()=>{if(!R)return;const G=D.trim()||t.url||"Untitled request",Se=Gr();if(j){g(Re=>({...Re,requests:Re.requests.map(Ge=>Ge.id===j?{...Ge,collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),updatedAt:Se}:Ge)}));return}const Ne={id:An("request"),collectionId:R.id,folderId:f||void 0,name:G,request:Ei(t),scripts:Sn(e),createdAt:Se,updatedAt:Se};g(Re=>({...Re,requests:[...Re.requests,Ne]})),M(Ne.id),E(G)},he=G=>{const Se=h.requests.find(Ne=>Ne.id===G);Se&&(M(Se.id),r?.(Se.collectionId),s?.(Se.folderId||""),E(Se.name),n(Ei(Se.request),Se.scripts?Sn(Se.scripts):void 0,Se.collectionId,Se.folderId))},ne=G=>{g(Se=>({...Se,requests:Se.requests.filter(Ne=>Ne.id!==G)})),j===G&&(M(null),E(""))},ke=G=>{const Se=h.folders.find(Ne=>Ne.id===G);g(Ne=>LC(Ne,G)),f===G&&s?.(Se?.parentFolderId||"")},_e=G=>{const Se=qC(h,G);g(Se),u===G&&(r?.(Se.collections[0]?.id||""),s?.(""),M(null),E(""))},$e=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Pe=v==="dark"?"text-gray-400":"text-gray-500",Ke=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Ie=G=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===G.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${G.name}`,onClick:()=>he(G.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:G.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:G.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${G.name} for Runner`,onClick:()=>me({type:"request",collectionId:G.collectionId,requestId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${G.name}`,onClick:()=>ne(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id),ut=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=ye(G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${Ge}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===G.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+Se*16}px`},onClick:()=>s?.(G.id),children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Run folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(G.collectionId,G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.collectionId,G.id).length===0,"aria-label":`Export folder ${Ge} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"folder",collectionId:G.collectionId,folderId:G.id},Ge),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${Ge}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>ke(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),st.map(Et=>ut(Et,Se+1,Re))]},G.id)},Rt=(G,Se,Ne=new Set)=>{if(Ne.has(G.id))return null;const Re=new Set(Ne);Re.add(G.id);const Ge=U.filter(Et=>Et.folderId===G.id),st=J.filter(Et=>Et.parentFolderId===G.id);return Ge.length===0&&st.length===0?null:p.jsxs("div",{className:"space-y-1",children:[Ge.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${Pe}`,style:{paddingLeft:`${8+Se*12}px`},children:G.name}),p.jsx("div",{style:{paddingLeft:`${Se*12}px`},children:Ge.map(Ie)})]}),st.map(Et=>Rt(Et,Se+1,Re))]},G.id)},Ce=J.filter(G=>!G.parentFolderId),Ee=f?ye(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:w,onChange:G=>A(G.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:fe,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(G=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${G.id===R?.id?Ke:""}`,onClick:()=>{r?.(G.id),s?.(""),M(null),E("")},children:G.name}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Run collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(G.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,G.id).length===0,"aria-label":`Export collection ${G.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>me({type:"collection",collectionId:G.id},G.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${G.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>_e(G.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},G.id))}),p.jsxs("p",{className:`text-xs ${Pe}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),R&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:R.auth,label:"Collection",hostExecution:b,onChange:L,theme:v}),p.jsx("p",{className:`text-xs ${Pe}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[R.variables.map((G,Se)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${Se+1} enabled`,type:"checkbox",checked:G.enabled!==!1,onChange:Ne=>ue(G.id,{enabled:Ne.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"baseUrl",value:G.key,onChange:Ne=>ue(G.id,{key:Ne.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${Se+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${$e}`,placeholder:"https://api.example.com",value:G.value,onChange:Ne=>ue(G.id,{value:Ne.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${Se+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>ve(G.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},G.id)),R.variables.length===0&&p.jsxs("p",{className:`text-xs ${Pe}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${$e}`,value:C,onChange:G=>O(G.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${Pe}`,children:Ee?`New folders are created inside ${Ee}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),Ce.map(G=>ut(G,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ee]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:Q,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:D,onChange:G=>E(G.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${$e}`,value:f,onChange:G=>s?.(G.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),W.map(({folder:G,depth:Se})=>p.jsx("option",{value:G.id,children:`${"— ".repeat(Se)}${G.name}`},G.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[U.filter(G=>!G.folderId).map(Ie),Ce.map(G=>Rt(G,0)),U.length===0&&p.jsx("p",{className:`px-2 text-xs ${Pe}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(O=>({...O,environments:[...O.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,name:w,updatedAt:A}:O)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(O=>({...O,environments:O.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(E=>E.id===w?{...E,...A}:E),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(O=>O.id===a.id?{...O,variables:O.variables.filter(D=>D.id!==w),updatedAt:A}:O)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? +`),f=a.length-(u+1),h=r[c]||"",g=s[c]||"",b=h.length-h.trimStart().length,v=g.length-g.trimStart().length,w=g.length-v,A=f<=b?Math.min(f,v):v+Math.min(f-b,w);return s.slice(0,c).reduce((E,D)=>E+D.length+1,0)+A}function t3(t,e,n=e){const r=t.replace(/\r\n?/g,` +`),s=e3(t),a=Yv(r,s,Pv(t,e)),c=Yv(r,s,Pv(t,n));return{value:s,selectionStart:Math.min(a,s.length),selectionEnd:Math.min(Math.max(a,c),s.length)}}const Xh=[{label:"get",kind:"method",signature:"get(key: string): string | undefined",documentation:"Read a variable by key."},{label:"has",kind:"method",signature:"has(key: string): boolean",documentation:"Check whether a variable is defined."},{label:"set",kind:"method",signature:"set(key: string, value: unknown): void",documentation:"Set a variable. Collection and environment stores persist the change in the workspace."},{label:"unset",kind:"method",signature:"unset(key: string): void",documentation:"Remove a variable by key."},{label:"replaceIn",kind:"method",signature:"replaceIn(value: string): string",documentation:"Replace {{variable}} placeholders using this variable scope."}],n3={flex:[{label:"request",kind:"property",documentation:"The mutable request draft available to pre-request and test scripts."},{label:"response",kind:"property",documentation:"The response from the executed request.",testsOnly:!0},{label:"environment",kind:"property",documentation:"Read and mutate variables in the active environment."},{label:"collection",kind:"property",documentation:"Read and mutate variables on the current collection."},{label:"variables",kind:"property",documentation:"Read and mutate the effective variables for this execution."},{label:"expect",kind:"function",signature:"expect(actual: unknown): FlexExpectation",documentation:"Create an assertion chain for a value."},{label:"test",kind:"function",signature:"test(name: string, callback: () => unknown | Promise): void",documentation:"Register a post-response test.",testsOnly:!0}],"flex.request":[{label:"method",kind:"property",signature:"method: string",documentation:"Read or replace the HTTP method."},{label:"url",kind:"property",signature:"url: string",documentation:"Read or replace the request URL before variable resolution."},{label:"headers",kind:"property",documentation:"Mutable request-header helpers."},{label:"body",kind:"property",documentation:"Mutable raw request-body helpers."}],"flex.request.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a request header case-insensitively."},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a request header exists."},{label:"set",kind:"method",signature:"set(name: string, value: unknown): void",documentation:"Set or replace a request header."},{label:"upsert",kind:"method",signature:"upsert({ key, value }: { key: string; value: unknown }): void",documentation:"Set or replace a request header from a key/value object."},{label:"remove",kind:"method",signature:"remove(name: string): void",documentation:"Remove a request header case-insensitively."},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return enabled request headers as an object."}],"flex.request.body":[{label:"raw",kind:"property",signature:"raw: string",documentation:"Read or replace the raw request body."}],"flex.response":[{label:"code",kind:"property",signature:"code: number",documentation:"HTTP response status code.",testsOnly:!0},{label:"status",kind:"property",signature:"status: string",documentation:"HTTP response status text.",testsOnly:!0},{label:"responseTime",kind:"property",signature:"responseTime: number",documentation:"Measured response time in milliseconds.",testsOnly:!0},{label:"headers",kind:"property",documentation:"Read-only response-header helpers.",testsOnly:!0},{label:"text",kind:"method",signature:"text(): string",documentation:"Return the response body as text.",testsOnly:!0},{label:"json",kind:"method",signature:"json(): unknown",documentation:"Parse and return the response body as JSON.",testsOnly:!0}],"flex.response.headers":[{label:"get",kind:"method",signature:"get(name: string): string | undefined",documentation:"Read a response header case-insensitively.",testsOnly:!0},{label:"has",kind:"method",signature:"has(name: string): boolean",documentation:"Check whether a response header exists.",testsOnly:!0},{label:"toObject",kind:"method",signature:"toObject(): Record",documentation:"Return response headers as an object.",testsOnly:!0}],"flex.environment":Xh,"flex.collection":Xh,"flex.variables":Xh.map(t=>({...t,documentation:t.label==="set"||t.label==="unset"?`${t.documentation} Local effective-variable changes apply only to the current request execution.`:t.documentation})),"flex.expect.to":[{label:"equal",kind:"method",signature:"equal(expected: unknown): void",documentation:"Assert strict equality with Object.is."},{label:"eql",kind:"method",signature:"eql(expected: unknown): void",documentation:"Assert deep structural equality."},{label:"include",kind:"method",signature:"include(expected: unknown): void",documentation:"Assert that a string or array contains the expected value."},{label:"match",kind:"method",signature:"match(pattern: RegExp): void",documentation:"Assert that a string matches a regular expression."},{label:"have",kind:"property",documentation:"Property assertions."},{label:"be",kind:"property",documentation:"Boolean, range, and membership assertions."}],"flex.expect.to.have":[{label:"property",kind:"method",signature:"property(name: string, expected?: unknown): void",documentation:"Assert that an object has a property, optionally with an expected value."}],"flex.expect.to.be":[{label:"above",kind:"method",signature:"above(expected: number): void",documentation:"Assert that a number is greater than expected."},{label:"below",kind:"method",signature:"below(expected: number): void",documentation:"Assert that a number is less than expected."},{label:"oneOf",kind:"method",signature:"oneOf(expected: unknown[]): void",documentation:"Assert deep equality with one value from a list."},{label:"ok",kind:"property",signature:"ok: true",documentation:"Assert that the value is truthy."},{label:"true",kind:"property",signature:"true: true",documentation:"Assert that the value is exactly true."},{label:"false",kind:"property",signature:"false: true",documentation:"Assert that the value is exactly false."}],console:[{label:"log",kind:"method",signature:"log(...values: unknown[]): void",documentation:"Write a line to the API Client script console."},{label:"info",kind:"method",signature:"info(...values: unknown[]): void",documentation:"Write an informational line to the API Client script console."},{label:"warn",kind:"method",signature:"warn(...values: unknown[]): void",documentation:"Write a warning line to the API Client script console."},{label:"error",kind:"method",signature:"error(...values: unknown[]): void",documentation:"Write an error line to the API Client script console."}]};function Kv(t,e){return[...n3[t]||[]].filter(n=>e==="tests"||!n.testsOnly).map(n=>({...n}))}function i3(t,e,n={}){const r=e.toLowerCase();return[...new Set(n[t]||[])].filter(Boolean).filter(s=>s.toLowerCase().startsWith(r)).sort((s,a)=>s.localeCompare(a)).map(s=>({label:s,kind:"variable",signature:s,documentation:`Known ${t==="variables"?"effective":t} variable.`}))}const r3=[{label:"flex",kind:"namespace",documentation:"FlexDoc request, response, variables, assertions, and test scripting API."},{label:"console",kind:"namespace",documentation:"Captured script console with log, info, warn, and error methods."}];function s3(t){const e=t.lastIndexOf("flex.expect(");if(e<0)return null;const n=t.slice(e),r=[[/\.to\.have\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.have"],[/\.to\.be\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to.be"],[/\.to\.([A-Za-z_$][\w$]*)?$/,"flex.expect.to"]];for(const[s,a]of r){const c=n.match(s);if(c)return{path:a,prefix:c[1]||""}}return null}function l3(t){const e=t.match(/flex\.(environment|collection|variables)\.(?:get|has|set|unset)\(\s*['"]([^'"]*)$/);return e?{scope:e[1],prefix:e[2]||""}:null}function a3(t){const e=t.match(/(?:^|[^\w$])((?:flex|console)(?:\.[A-Za-z_$][\w$]*)*)\.([A-Za-z_$][\w$]*)?$/);return e?{path:e[1],prefix:e[2]||""}:null}function o3(t,e,n,r={},s=!1){const a=Math.max(0,Math.min(e,t.length)),c=t.slice(0,a),u=l3(c);if(u){const v=i3(u.scope,u.prefix,r);return v.length>0?{from:a-u.prefix.length,to:a,items:v}:null}const f=s3(c);if(f){const v=Kv(f.path,n).filter(w=>w.label.toLowerCase().startsWith(f.prefix.toLowerCase()));return v.length>0?{from:a-f.prefix.length,to:a,items:v}:null}const h=a3(c);if(h){const v=Kv(h.path,n).filter(w=>w.label.toLowerCase().startsWith(h.prefix.toLowerCase()));return v.length>0?{from:a-h.prefix.length,to:a,items:v}:null}const g=c.match(/([A-Za-z_$][\w$]*)$/)?.[1]||"";if(!s&&!g)return null;const b=r3.filter(v=>!g||v.label.startsWith(g));return!s&&b.length===0?null:b.length>0?{from:a-g.length,to:a,items:b.map(v=>({...v}))}:null}const Gv=({ariaLabel:t,value:e,onChange:n,phase:r,theme:s="light",variableKeys:a={}})=>{const c=I.useRef(null),u=I.useRef(null),f=I.useRef([]),[h,g]=I.useState(null),[b,v]=I.useState(0),[w,A]=I.useState({left:12,top:36}),C=I.useMemo(()=>`api-client-script-completions-${t.toLowerCase().replace(/[^a-z0-9]+/g,"-")}`,[t]),E=I.useMemo(()=>WO(e),[e]),D=s==="dark",O=B=>{const K=u.current,ee=c.current;if(!K||!ee)return;const be=K.coordsAtPos(B);if(!be)return;const ce=ee.getBoundingClientRect(),ge=be.left-ce.left,q=Math.max(8,ce.width-430),J=be.bottom-ce.top+2,oe=Math.max(8,ce.height-96);A({left:Math.max(8,Math.min(ge,q)),top:Math.max(8,Math.min(J,oe))})},j=(B,K,ee=!1)=>{const be=o3(B,K,r,a,ee);g(be),v(0),be&&requestAnimationFrame(()=>O(K))},R=B=>{if(!h)return;const K=`${e.slice(0,h.from)}${B.label}${e.slice(h.to)}`,ee=h.from+B.label.length;n(K),g(null),requestAnimationFrame(()=>{u.current?.setSelection(ee)})},_=()=>{if(!E.valid)return;const B=u.current?.getSelection()??{from:e.length,to:e.length},K=t3(e,B.from,B.to);K.value!==e&&n(K.value),g(null),requestAnimationFrame(()=>{u.current?.setSelection(K.selectionStart,K.selectionEnd)})};I.useEffect(()=>{f.current[b]?.scrollIntoView({block:"nearest"})},[b]);const L=B=>{const K=u.current?.getSelection().from??e.length;if((B.ctrlKey||B.metaKey)&&B.code==="Space"){B.preventDefault(),j(e,K,!0);return}if(B.shiftKey&&B.altKey&&B.code==="KeyF"){B.preventDefault(),_();return}if(!(!h||h.items.length===0)){if(B.key==="ArrowDown"){B.preventDefault(),v(ee=>(ee+1)%h.items.length);return}if(B.key==="ArrowUp"){B.preventDefault(),v(ee=>(ee-1+h.items.length)%h.items.length);return}if(B.key==="Enter"||B.key==="Tab"){B.preventDefault(),R(h.items[b]);return}B.key==="Escape"&&(B.preventDefault(),g(null))}},M=h?.items[b],G=!!h&&h.items.length>0,Y=D?"border-gray-700 bg-gray-900 text-gray-100 shadow-2xl":"border-gray-200 bg-white text-gray-900 shadow-2xl";return p.jsxs("div",{ref:c,className:"relative min-w-0",onBlur:B=>{B.currentTarget.contains(B.relatedTarget)||g(null)},children:[p.jsxs("div",{className:"mb-1 flex flex-wrap items-center justify-between gap-2",children:[p.jsxs("span",{role:E.valid?"status":"alert",className:`inline-flex items-center gap-1 text-[11px] ${E.valid?D?"text-emerald-300":"text-emerald-700":D?"text-amber-300":"text-amber-700"}`,children:[E.valid?p.jsx(oa,{className:"h-3.5 w-3.5"}):p.jsx(Ed,{className:"h-3.5 w-3.5"}),p.jsx("span",{className:"max-w-[24rem] truncate",children:E.message})]}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs disabled:cursor-not-allowed disabled:opacity-50",disabled:!E.valid||!e.trim(),onMouseDown:B=>B.preventDefault(),onClick:_,"aria-label":"Format current script",children:[p.jsx(rk,{className:"h-3.5 w-3.5"}),"Format"]})]}),p.jsx(Ha,{ref:u,ariaActiveDescendant:G?`${C}-${b}`:void 0,ariaAutocomplete:"list",ariaControls:G?C:void 0,ariaExpanded:G,ariaLabel:t,autoIndent:!0,dataTestId:`${t}-editor`,language:"javascript",onChange:B=>{const K=u.current?.getSelection().from??B.length;n(B),requestAnimationFrame(()=>{const ee=u.current?.getSelection().from??K;j(B,ee)})},onCursorChange:B=>{h&&O(B)},onEditorKeyDown:L,theme:s,value:e,wrap:!0}),G&&p.jsxs("div",{className:`absolute z-[70] w-[min(26rem,calc(100%-1rem))] overflow-hidden rounded-md border ${Y}`,"data-testid":`${t}-completion-popup`,style:{left:w.left,top:w.top},children:[p.jsx("div",{id:C,role:"listbox","aria-label":"Script suggestions",className:"max-h-56 overflow-y-auto py-1",children:h.items.map((B,K)=>p.jsxs("button",{ref:ee=>{f.current[K]=ee},"aria-label":B.label,"aria-selected":K===b,className:`flex w-full items-baseline gap-2 px-3 py-1.5 text-left text-xs ${K===b?D?"bg-blue-700 text-white":"bg-blue-50 text-gray-900":D?"hover:bg-gray-800":"hover:bg-gray-50"}`,id:`${C}-${K}`,onMouseEnter:()=>v(K),onMouseDown:ee=>{ee.preventDefault(),R(B)},role:"option",type:"button",children:[p.jsx("span",{"aria-hidden":"true",className:"shrink-0 rounded bg-black/5 px-1 font-mono text-[10px] uppercase opacity-60 dark:bg-white/10",children:B.kind}),p.jsx("span",{className:"font-mono font-semibold",children:B.label}),p.jsx("span",{"aria-hidden":"true",className:`min-w-0 truncate ${K===b&&D?"text-blue-100":D?"text-gray-400":"text-gray-500"}`,children:B.signature||""})]},`${B.kind}-${B.label}`))}),M&&p.jsxs("div",{className:`border-t px-3 py-2 text-[11px] ${D?"border-gray-700 text-gray-300":"border-gray-200 text-gray-600"}`,children:[M.signature&&p.jsx("div",{className:"mb-1 overflow-x-auto whitespace-nowrap font-mono text-xs",children:M.signature}),p.jsx("div",{children:M.documentation})]})]}),p.jsxs("div",{className:`mt-1 flex flex-wrap gap-x-3 text-[11px] ${D?"text-gray-400":"text-gray-500"}`,children:[p.jsxs("span",{children:[p.jsx("code",{children:"flex."})," or Ctrl+Space"]}),p.jsx("span",{children:"Enter keeps indentation"}),p.jsx("span",{children:"↑/↓ choose"}),p.jsx("span",{children:"Enter/Tab complete"}),p.jsx("span",{children:"Shift+Alt+F format"})]})]})},Xv=new Set,Gc="API-host execute route",Xc="the execute path";function Jc(t,e){return`${Gc} diagnostic ${t}. Check ${e}.`}function c3(t,e){return t===401?Jc("was unauthorized",`documentation authentication for ${Xc}`):t===403?Jc("was rejected",`CSRF, same-origin, and authorization middleware for ${Xc}`):t===404||t===501||t===405&&(!e||!/\bPOST\b/i.test(e))?`${Gc} is not available at the configured endpoint. Deploy the FlexDoc execute route or update the API-host URL.`:t===400?`${Gc} returned HTTP 400 before FlexDoc validated the diagnostic probe. Check CSRF and request-body middleware for ${Xc}.`:Jc(`returned HTTP ${t}`,"authentication, CSRF, and middleware configuration")}async function u3(t,e=globalThis.fetch,n){const r=t.trim();if(!r||!e||n?.aborted)return null;const s=e===globalThis.fetch;if(s&&Xv.has(r))return null;try{const a=await e(r,{method:"POST",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1","Content-Type":"application/json"},body:"{}",signal:n});if(n?.aborted)return null;const c=await a.text();let u="";try{const h=c?JSON.parse(c):{};typeof h.error=="string"&&(u=h.error)}catch{}return a.status===429||a.status===400&&/host execution/i.test(u)?(s&&Xv.add(r),null):a.redirected?Jc("was redirected",`authentication middleware for ${Xc}`):a.ok?`${Gc} accepted the deliberately invalid diagnostic request. Verify that the configured endpoint is FlexDoc's hardened execute route.`:c3(a.status,a.headers.get("Allow"))}catch{return null}}function d3(t){let e=t.url;for(const[n,r]of Object.entries(t.variables||{}))e=e.split(`{${n}}`).join(r.default);return e}function Jh(t){return t.replace(/\/+$/,"")}function Jv(t,e){const n=Jh(e);return n?t===n||t.startsWith(`${n}/`)||t.startsWith(`${n}?`):!1}function f3(t,e,n){const r=Jh(n);if(!r)return t;const s=Jh(e);if(s&&Jv(t,s))return`${r}${t.slice(s.length)}`;try{const a=new URL(t),c=`${a.pathname==="/"?"":a.pathname}${a.search}${a.hash}`;return`${r}${c}`}catch{return r}}const Qv="Credential storage changed, but the API-host cookie jar could not be confirmed cleared. It may still hold session cookies until it expires.";function h3(t){if(t.hostExecution?.cookieJar!=="session")return t;const e={...t.hostExecution};return delete e.cookieJar,{...t,hostExecution:Object.keys(e).length?e:void 0}}function p3(t){return t?.available!==!0||!(t.capabilities||[]).includes("cookies")?null:t.cookiesEndpoint?.trim()||null}async function m3(t,e=globalThis.fetch){const n=p3(t);if(!n||typeof e!="function")return null;try{return(await e(n,{method:"DELETE",credentials:"same-origin",headers:{"X-FlexDoc-Execute":"1"}})).ok?null:Qv}catch{return Qv}}const g3=()=>({key:"",value:"",enabled:!0});function y3(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode||ha(t||{}),urlencoded:t?.urlencoded?.length?t.urlencoded.map(e=>({...e})):void 0,formData:t?.formData?.length?t.formData.map(e=>({...e})):void 0,binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,auth:t?.auth||{type:"none"},hostExecution:t?.hostExecution?{...t.hostExecution}:void 0}}function b3(t){const e=t.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:void 0;return{...t,query:t.query?.map(n=>({...n})),headers:t.headers?.map(n=>({...n})),urlencoded:t.urlencoded?.map(n=>({...n})),formData:t.formData?.map(n=>({...n})),binary:t.binary?{...t.binary}:void 0,graphql:t.graphql?{...t.graphql}:void 0,auth:e,hostExecution:t.hostExecution?{...t.hostExecution}:void 0}}function x3(t){try{return new URL(t).origin}catch{return""}}function v3(t,e){if(t==="query"){const n=e.trim().replace(/^\?/,"").replace(/\r?\n/g,"&");return n?[...new URLSearchParams(n).entries()].map(([r,s])=>({key:r,value:s,enabled:!0})):[]}return e.split(/\r?\n/).map(n=>n.trim()).filter(Boolean).flatMap(n=>{const r=n.indexOf(":");return r<=0?[]:[{key:n.slice(0,r).trim(),value:n.slice(r+1).trim(),enabled:!0}]})}function Wv({kind:t,label:e,entries:n,onChange:r,inputClass:s,mutedClass:a}){const[c,u]=I.useState(""),f=(g,b)=>r(n.map((v,w)=>w===g?{...v,...b}:v)),h=()=>{const g=v3(t,c);g.length&&(r(g),u(""))};return p.jsxs("div",{className:"space-y-3",children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[p.jsx("span",{className:"text-sm font-medium",children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>r([...n,g3()]),children:[p.jsx(ks,{className:"h-4 w-4"})," Add"]})]}),n.length===0&&p.jsxs("div",{className:`rounded-md border border-dashed p-3 text-sm ${a}`,children:["No ",t==="query"?"query parameters":"headers"," configured."]}),n.map((g,b)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-start gap-2 sm:grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto]",children:[p.jsx("input",{className:"mt-3","aria-label":`${e} ${b+1} enabled`,type:"checkbox",checked:g.enabled!==!1,onChange:v=>f(b,{enabled:v.target.checked})}),p.jsx("input",{"aria-label":`${e} ${b+1} key`,className:`min-w-0 w-full rounded-md border px-3 py-2 text-sm ${s}`,placeholder:"Key",value:g.key,onChange:v=>f(b,{key:v.target.value})}),p.jsx("input",{"aria-label":`${e} ${b+1} value`,className:`col-start-2 min-w-0 w-full rounded-md border px-3 py-2 text-sm sm:col-start-auto ${s}`,placeholder:"Value",value:g.value,onChange:v=>f(b,{value:v.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove ${e.toLowerCase()} ${b+1}`,className:"col-start-3 row-start-1 inline-flex min-h-11 items-center justify-center rounded-md border px-3 py-2 sm:col-start-auto sm:row-start-auto",onClick:()=>r(n.filter((v,w)=>w!==b)),children:p.jsx(fi,{className:"h-4 w-4"})})]},b)),p.jsxs("details",{className:"rounded-md border p-3",children:[p.jsx("summary",{className:"cursor-pointer text-xs font-medium",children:"Bulk edit"}),p.jsxs("div",{className:"mt-2 space-y-2",children:[p.jsx("textarea",{"aria-label":`${e} bulk editor`,className:`min-h-24 w-full rounded-md border px-3 py-2 font-mono text-xs ${s}`,placeholder:t==="query"?"a=1&b=2":`Accept: application/json +X-Trace: abc123`,value:c,onChange:g=>u(g.target.value)}),p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:`text-xs ${a}`,children:t==="query"?"Paste query-string pairs; applying replaces the current rows.":"Paste raw Header: value lines; applying replaces the current rows."}),p.jsx("button",{type:"button",className:"rounded-md border px-3 py-1.5 text-xs",disabled:!c.trim(),onClick:h,children:"Apply"})]})]})]})]})}function Zv(t){return(t||[]).filter(e=>e.enabled!==!1&&e.key.trim()).length}function w3(t,e){const n=[...t.matchAll(/\{\{\s*([^{}]+?)\s*\}\}/g)].map(c=>c[1].trim()),r=[...new Set(n)],s=r.filter(c=>!Object.prototype.hasOwnProperty.call(e,c)),a=t.replace(/\{\{\s*([^{}]+?)\s*\}\}/g,(c,u)=>{const f=u.trim();return Object.prototype.hasOwnProperty.call(e,f)?e[f]:c});return{names:r,missing:s,resolved:a}}const e1=({initialRequest:t,initialScripts:e,initialRequestTab:n="params",initialScriptTab:r,theme:s="light",density:a="advanced",messages:c,credentials:u="same-origin",requestInterceptor:f,onRequestChange:h,onDraftChange:g,onScriptsChange:b,onRequestTabChange:v,onScriptTabChange:w,onExecutionStart:A,onExecutionComplete:C,resolveAuth:E,variables:D={},collectionVariables:O={},externalVariables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,serverOptions:M=[],initialServerUrl:G,onServerUrlChange:Y,hostExecution:B,credentialStorage:K,onCredentialStorageChange:ee})=>{const be=y3(t),ce=Sn(e),ge=M.map(se=>({server:se,url:d3(se)})),q=ge.map(se=>se.url),J=G||q.find(se=>Jv(be.url,se))||"",oe=q.includes(J)?J:q[0]||"",he=J&&!q.includes(J)?J:"",Se=J||oe||x3(be.url),[T,z]=I.useState(be),[me,ne]=I.useState(ce),[Ce,Re]=I.useState(oe),[qe,He]=I.useState(he),Je=I.useRef(Se),Be=I.useRef(Se),[dt,At]=I.useState(null),[yt,Ge]=I.useState(),[Q,re]=I.useState(null),[ve,Ne]=I.useState(null),[$e,We]=I.useState([]),[vt,ti]=I.useState([]),[Tn,ft]=I.useState(!1),[ni,Vn]=I.useState(null),qn=I.useRef(null),kt=I.useRef(0),x=I.useRef(h),U=I.useRef(g),pe=I.useRef(b),ue=I.useRef(null),[X,k]=I.useState(n),[V,W]=I.useState(()=>r||(ce.tests.trim()&&!ce.preRequest.trim()?"tests":"pre-request")),we=I.useRef({}),F=I.useRef({}),de=I.useId().replace(/:/g,""),ae=I.useId().replace(/:/g,"");I.useEffect(()=>{x.current=h},[h]),I.useEffect(()=>{U.current=g},[g]),I.useEffect(()=>{pe.current=b},[b]),I.useEffect(()=>{U.current?.(b3(T))},[T]),I.useEffect(()=>{pe.current?.(Sn(me))},[me]),I.useEffect(()=>{try{const se=E?{...T,auth:E(T.auth)}:T,De=G0(se,{variables:D}),Qe=JSON.stringify([De.method,De.url,De.headerEntries,De.body,De.bodyKind]);if(Qe===ue.current)return;ue.current=Qe,x.current?.(De)}catch{}},[T,E,D]);const Ae=(T.method||"GET").toUpperCase(),Ee=["GET","HEAD"].includes(Ae),Te=s==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",Le=`rounded-md border px-3 py-2 text-sm ${Te}`,ze=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",Ve=s==="dark"?"text-gray-400":"text-gray-600",Dt=X==="scripts"&&a!=="advanced"?"params":X,Fn=Zv(T.query),jn=Zv(T.headers),Va=!!T.auth&&T.auth.type!=="none"&&T.auth.type!=="inherit",qs=ha(T)!=="none",Bs=!!(me.preRequest.trim()||me.tests.trim()),Ze=[{id:"params",label:"Params",count:Fn},{id:"headers",label:"Headers",count:jn},{id:"authorization",label:"Authorization",active:Va},{id:"body",label:"Body",active:qs},{id:"scripts",label:"Scripts",active:Bs}].filter(se=>a==="advanced"||se.id!=="scripts"),$t=se=>`${de}-request-tab-${se}`,Bn=se=>`${de}-request-panel-${se}`,ii=se=>`${ae}-script-tab-${se}`,En=se=>`${ae}-script-panel-${se}`,_t=w3(T.url,D),Yt=se=>{se==="scripts"&&a!=="advanced"||(k(se),v?.(se))},Pn=se=>{W(se),w?.(se)},Jr=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=Ze.filter(On=>!On.disabled).map(On=>On.id),ri=Math.max(0,Qe.indexOf(De)),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Yt(Jt),we.current[Jt]?.focus()},kl=(se,De)=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(se.key))return;se.preventDefault();const Qe=["pre-request","tests"],ri=Qe.indexOf(De),Jt=se.key==="Home"?Qe[0]:se.key==="End"?Qe[Qe.length-1]:se.key==="ArrowRight"?Qe[(ri+1)%Qe.length]:Qe[(ri-1+Qe.length)%Qe.length];Pn(Jt),F.current[Jt]?.focus()},Li=se=>{if(!se)return;const De=Je.current;Je.current=se,Y?.(se),z(Qe=>({...Qe,url:f3(Qe.url,De,se)}))},Fa=E?E(T.auth):T.auth,Qr=Fo({request:{...T,auth:Fa},hostExecution:B}),[Cl,ur,dr]=Qr,Wr=Cl==="host-required",fr=dr?B?.available?c?.unusualBodyHostExecution||`${Ae} request bodies are unusual. FlexDoc will use API-host execution so the body can be sent.`:c?.unusualBodyBrowserWarning||`${Ae} request bodies are unusual. Browser fetch may reject this request; enable API-host execution to send it reliably.`:tN(Qr,B,c?.hostBrowserUnsupported,c?.hostExecutionDisabled),Xt=se=>B?.available===!0&&(B.capabilities||[]).includes(se),ru=se=>{if(!ee||se===(K||"remember"))return;ee(se),z(Qe=>h3(Qe));const De=kt.current+1;kt.current=De,m3(B).then(Qe=>{kt.current===De&&Vn(Qe)})},Nl=eN(dt,{...T,auth:Fa},B),Qi=async()=>{if(Tn)return;const se=new AbortController;qn.current=se,A?.(),ft(!0),re(null),Ne(null),We([]),ti([]),At(null),Ge(void 0);try{const De=await by({request:T,scripts:me,credentials:u,requestInterceptor:f,resolveAuth:E,variables:D,collectionVariables:O,externalVariables:j,environmentVariables:R,hostExecution:B,signal:se.signal,onRequestBuilt:Jt=>x.current?.(Jt),onCollectionChanges:_,onEnvironmentChanges:L});if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}let Qe=De.error||null;if(Qe&&De.result?.transport==="api-host"&&B?.endpoint){const Jt=await u3(B.endpoint,globalThis.fetch,se.signal);if(se.signal.aborted){re(c?.requestCancelled||"Request cancelled.");return}Jt&&(Qe=`${Qe} ${Jt}`)}const ri=WC(De,T,B);Qe&&ri&&(Qe=`${Qe} ${ri}`),re(Qe),Ne(De.scriptError||null),We(De.scriptTests),ti(De.scriptLogs),De.response&&(Ge(De.curlCommand),At(De.response)),De.result&&C?.(De.result)}finally{qn.current===se&&(qn.current=null),ft(!1)}},Zr=()=>qn.current?.abort(),hp=$e.filter(se=>se.passed).length,Pa=!Tn&&!(Wr&&!ur);return p.jsx("div",{className:`min-w-0 rounded-xl border p-4 md:p-5 ${ze}`,"data-api-client-editor":!0,onKeyDown:se=>{(se.ctrlKey||se.metaKey)&&se.key==="Enter"&&Pa&&(se.preventDefault(),Qi())},children:p.jsxs("div",{className:"flex flex-col gap-4",children:[p.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[M.length>0&&p.jsxs("label",{className:"text-sm font-medium",children:["Server",p.jsx("select",{"aria-label":"API Client server",className:`mt-1 w-full rounded-md border px-3 py-2 text-sm ${Te}`,value:Ce,onChange:se=>{Re(se.target.value),He(""),Li(se.target.value)},children:ge.map(({server:se,url:De})=>p.jsxs("option",{value:De,children:[se.description?`${se.description} — `:"",se.url]},`${se.url}:${De}`))})]}),p.jsxs("label",{className:"text-sm font-medium",children:["Custom server URL ",p.jsx("span",{className:"text-xs font-normal opacity-70",children:"(optional override)"}),p.jsx("input",{"aria-label":"API Client custom server URL",className:`mt-1 w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,value:qe,onChange:se=>{const De=se.target.value;He(De);const Qe=Ce||Be.current;(De.trim()||Qe)&&Li(De.trim()||Qe)},placeholder:"http://localhost:8080"})]})]}),p.jsxs("div",{className:"grid min-w-0 gap-2 sm:grid-cols-[auto_minmax(0,1fr)]",children:[p.jsx("select",{"aria-label":"HTTP method",className:`rounded-md border px-3 py-2 font-medium ${Te}`,value:Ae,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,method:De}))},children:["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(se=>p.jsx("option",{children:se},se))}),p.jsx("input",{"aria-label":"Request URL",className:`w-full rounded-md border px-3 py-2 font-mono text-sm ${Te}`,placeholder:"https://api.example.com/resource or {{baseUrl}}/resource",value:T.url,onChange:se=>{const De=se.target.value;z(Qe=>({...Qe,url:De}))}})]}),_t.names.length>0&&p.jsx("div",{className:`rounded-md border px-3 py-2 text-xs ${_t.missing.length?s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800":s==="dark"?"border-gray-700 bg-gray-900 text-gray-300":"border-gray-200 bg-white text-gray-600"}`,children:_t.missing.length>0?p.jsxs(p.Fragment,{children:["Missing URL variable",_t.missing.length===1?"":"s",": ",p.jsx("strong",{children:_t.missing.join(", ")}),"."]}):p.jsxs(p.Fragment,{children:["Resolved URL: ",p.jsx("code",{className:"break-all",children:_t.resolved})]})}),p.jsx("div",{className:"-mx-1 overflow-x-auto px-1 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden","data-api-client-request-tabs":!0,children:p.jsx("div",{className:`flex min-w-max gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Request configuration",children:Ze.map(se=>p.jsxs("button",{ref:De=>{we.current[se.id]=De},id:$t(se.id),type:"button",role:"tab","aria-controls":Bn(se.id),"aria-label":se.label,"aria-selected":Dt===se.id,tabIndex:Dt===se.id?0:-1,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-2 text-sm font-medium transition ${Dt===se.id?"bg-blue-600 text-white shadow-sm":s==="dark"?"text-gray-300 hover:bg-gray-800":"text-gray-600 hover:bg-gray-100"}`,onClick:()=>Yt(se.id),onKeyDown:De=>Jr(De,se.id),children:[p.jsx("span",{children:se.label}),se.count!==void 0&&se.count>0&&p.jsx("span",{className:`rounded-full px-1.5 text-[10px] leading-5 ${Dt===se.id?"bg-white/20 text-white":s==="dark"?"bg-gray-700 text-gray-200":"bg-gray-200 text-gray-700"}`,children:se.count}),se.active&&se.count===void 0&&p.jsx("span",{"aria-label":"Configured",className:`h-1.5 w-1.5 rounded-full ${Dt===se.id?"bg-white":"bg-blue-500"}`})]},se.id))})}),Ee&&p.jsx("p",{className:`-mt-2 text-xs ${Ve}`,children:c?.unusualBodyAdvisory||`${Ae} request bodies are unusual and may be ignored or rejected by servers or intermediaries. FlexDoc keeps the body; API-host execution can send it when available, while browser fetch may reject it.`}),Dt==="params"&&p.jsx("div",{role:"tabpanel",id:Bn("params"),"aria-labelledby":$t("params"),children:p.jsx(Wv,{kind:"query",label:"Query parameters",entries:T.query||[],onChange:se=>z(De=>({...De,query:se})),inputClass:Te,mutedClass:Ve})}),Dt==="headers"&&p.jsx("div",{role:"tabpanel",id:Bn("headers"),"aria-labelledby":$t("headers"),children:p.jsx(Wv,{kind:"headers",label:"Headers",entries:T.headers||[],onChange:se=>z(De=>({...De,headers:se})),inputClass:Te,mutedClass:Ve})}),Dt==="authorization"&&p.jsxs("div",{role:"tabpanel",id:Bn("authorization"),"aria-labelledby":$t("authorization"),className:"space-y-3",children:[p.jsx(bf,{auth:T.auth||{type:"none"},label:"",allowInherit:!!E,advanced:a==="advanced",hostExecution:B,onChange:se=>z(De=>({...De,auth:se})),theme:s}),ee&&p.jsxs("label",{className:"block text-sm font-medium",children:["Credential storage",p.jsxs("select",{"aria-label":"Credential storage",className:Le,value:K||"remember",onChange:se=>ru(se.target.value),children:[p.jsx("option",{value:"session",children:"Session only"}),p.jsx("option",{value:"remember",children:"Remember on this browser"}),p.jsx("option",{value:"never",children:"Never store"})]}),p.jsxs("span",{className:`mt-1 block text-xs font-normal ${Ve}`,children:["Applies to request, collection, and folder credentials. ",K==="session"?"Kept in this tab, not IndexedDB.":K==="never"?"Memory only; cleared on reload.":"Stored in this browser workspace."]})]}),ni&&p.jsx("p",{role:"status","aria-label":"API-host cookie jar",className:`text-xs ${s==="dark"?"text-amber-200":"text-amber-800"}`,children:ni}),a==="advanced"&&B?.available&&p.jsxs("div",{className:"grid gap-2 rounded-md border p-3 sm:grid-cols-2",children:[B.clientCertificates?.length?p.jsxs("label",{className:"text-xs font-medium",children:["Client certificate",p.jsxs("select",{"aria-label":"Client certificate",className:`mt-1 w-full rounded-md border px-2 py-1.5 ${Te}`,value:T.hostExecution?.certificateId||"",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},certificateId:se.target.value||void 0}})),children:[p.jsx("option",{value:"",children:"None"}),B.clientCertificates.map(se=>p.jsx("option",{value:se.id,children:se.name},se.id))]})]}):null,Xt("cookies")&&p.jsxs("label",{className:"inline-flex items-center gap-2 text-xs font-medium",children:[p.jsx("input",{"aria-label":"Use API host cookie jar",type:"checkbox",checked:T.hostExecution?.cookieJar==="session",onChange:se=>z(De=>({...De,hostExecution:{...De.hostExecution||{},cookieJar:se.target.checked?"session":void 0}}))}),"Use API host cookie jar"]})]})]}),Dt==="body"&&p.jsx("div",{role:"tabpanel",id:Bn("body"),"aria-labelledby":$t("body"),children:p.jsx(YO,{draft:T,onChange:z,theme:s})}),a==="advanced"&&Dt==="scripts"&&p.jsxs("section",{role:"tabpanel",id:Bn("scripts"),"aria-labelledby":$t("scripts"),className:"min-w-0 space-y-3",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-scripts-heading",className:"font-semibold",children:"Scripts"}),p.jsx("p",{className:`text-xs ${Ve}`,children:"Trusted local JavaScript. Editors soft-wrap, keep indentation, format only when you choose Format or Shift+Alt+F, and show lightweight syntax diagnostics."})]}),p.jsx("div",{className:`inline-flex max-w-full gap-1 rounded-lg border p-1 ${s==="dark"?"border-gray-700 bg-gray-900/70":"border-gray-200 bg-white"}`,role:"tablist","aria-label":"Script phase",children:["pre-request","tests"].map(se=>p.jsxs("button",{ref:De=>{F.current[se]=De},id:ii(se),type:"button",role:"tab","aria-controls":En(se),"aria-selected":V===se,tabIndex:V===se?0:-1,className:`rounded-md px-3 py-1.5 text-sm ${V===se?"bg-blue-600 text-white":""}`,onClick:()=>Pn(se),onKeyDown:De=>kl(De,se),children:[se==="pre-request"?"Pre-request":"Tests",(se==="pre-request"?me.preRequest:me.tests).trim()&&p.jsx("span",{"aria-label":"Configured",className:`ml-1.5 inline-block h-1.5 w-1.5 rounded-full ${V===se?"bg-white":"bg-blue-500"}`})]},se))}),V==="pre-request"?p.jsx("div",{role:"tabpanel",id:En("pre-request"),"aria-labelledby":ii("pre-request"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Pre-request script",phase:"pre-request",theme:s,value:me.preRequest,onChange:se=>ne(De=>({...De,preRequest:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})}):p.jsx("div",{role:"tabpanel",id:En("tests"),"aria-labelledby":ii("tests"),className:"min-w-0",children:p.jsx(Gv,{ariaLabel:"Tests script",phase:"tests",theme:s,value:me.tests,onChange:se=>ne(De=>({...De,tests:se})),variableKeys:{environment:Object.keys(R),collection:Object.keys(O),variables:Object.keys(D)}})})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:[p.jsx("span",{"aria-label":"Request transport",className:`rounded border px-2 py-1 ${Ve}`,children:QC(Cl)}),B?.available&&p.jsxs("label",{className:`inline-flex items-center gap-2 ${Ve}`,children:["Transport preference",p.jsxs("select",{"aria-label":"Transport preference",disabled:Wr,className:`rounded-md border px-2 py-1 ${Te}`,value:T.hostExecution?.preferHostExecution===void 0?"inherit":T.hostExecution.preferHostExecution?"host":"browser",onChange:({target:{value:se}})=>z(De=>({...De,hostExecution:{...De.hostExecution||{},preferHostExecution:se==="inherit"?void 0:se==="host"}})),children:[p.jsx("option",{value:"inherit",children:"Server default"}),p.jsx("option",{value:"browser",children:"Prefer browser"}),p.jsx("option",{value:"host",children:"Prefer API host"})]})]})]}),(Nl||fr||B?.available)&&p.jsx(yf,{message:Nl||fr||"FlexDoc API host is available.",capabilities:B?.capabilities,warning:!!Nl||!ur&&!dr,theme:s,label:c?.hostExecutionStatus||"Host execution status"}),Tn?p.jsxs("button",{type:"button",onClick:Zr,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md border border-red-500 px-4 py-2 font-medium text-red-600 sm:w-auto",children:[p.jsx(Ug,{className:"h-4 w-4"}),c?.cancelRequest||"Cancel request"]}):p.jsxs("button",{type:"button","data-api-client-send":"true",onClick:()=>{Qi()},disabled:!Pa,"aria-keyshortcuts":"Control+Enter Meta+Enter",title:`${c?.sendRequest||"Send request"} (Ctrl/Cmd+Enter)`,className:"inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-md bg-blue-600 px-4 py-2 font-medium text-white hover:bg-blue-700 disabled:opacity-60 sm:w-auto",children:[p.jsx(ca,{className:"h-4 w-4"})," ",c?.sendRequest||"Send request"," ",p.jsx("span",{className:"text-xs font-normal opacity-80",children:"Ctrl/Cmd+Enter"})]}),Q&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-700"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),Q]}),ve&&p.jsxs("div",{role:"alert",className:`flex gap-2 rounded-md border p-3 text-sm ${s==="dark"?"border-amber-800 bg-amber-950/40 text-amber-200":"border-amber-300 bg-amber-50 text-amber-800"}`,children:[p.jsx(Ad,{className:"mt-0.5 h-4 w-4 shrink-0"}),ve]}),dt&&p.jsx(QO,{response:dt,theme:s,curlCommand:yt,advanced:a==="advanced"}),$e.length>0&&p.jsxs("section",{className:"space-y-2","aria-labelledby":"api-client-test-results-heading",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("h3",{id:"api-client-test-results-heading",className:"font-semibold",children:"Test results"}),p.jsxs("span",{className:`text-xs ${Ve}`,children:[hp,"/",$e.length," passed"]})]}),p.jsx("div",{className:"space-y-2",children:$e.map((se,De)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${se.passed?s==="dark"?"border-green-800 bg-green-950/40 text-green-200":"border-green-300 bg-green-50 text-green-800":s==="dark"?"border-red-800 bg-red-950/40 text-red-200":"border-red-300 bg-red-50 text-red-800"}`,children:[p.jsxs("div",{className:"font-medium",children:[se.passed?"PASS":"FAIL"," — ",se.name]}),se.error&&p.jsx("div",{className:"mt-1 text-xs",children:se.error})]},`${se.name}:${De}`))})]}),vt.length>0&&p.jsx(Rr,{code:vt.join(` +`),language:"text",title:"Script console",theme:s,wrap:!0})]})})};function Qh(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}function S3(t,e){return t==="scripts"||e?"advanced":typeof window>"u"?"basic":new URLSearchParams(window.location.search).get("density")==="advanced"?"advanced":"basic"}function t1(t,e){return JSON.stringify({request:t,scripts:e},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}const A3=({spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:a,initialScriptTab:c,onRequestChange:u,onOpenInApiClient:f})=>{const h=t.paths[e],b=h?.[n.toLowerCase()]?.servers||h?.servers||t.servers||[],v=s?.tryIt?.apiClientPersistenceKey??ly(t.info?.title,typeof window>"u"?void 0:window.location.host),w=I.useMemo(()=>{const ne={...q0(t,e,n),serverUrl:s?.tryIt?.defaultServer};return uC(t,e,n,ne,s?.tryIt?.defaultServer)},[n,s?.tryIt?.defaultServer,e,t]),A=I.useMemo(()=>Sn(),[]),[C,E]=I.useState(()=>S3(a,c)),[D,O]=I.useState(w.request),[j,R]=I.useState(w.serverUrl),[_,L]=I.useState(A),[M,G]=I.useState(a||"params"),[Y,B]=I.useState(c||"pre-request"),[K,ee]=I.useState(()=>nl()),[be,ce]=I.useState(v===!1),ge=s?.messages;I.useEffect(()=>{if(v===!1)return;let ne=!1;return hy(v).then(Ce=>{ne||(ee(Ce),ce(!0))}).catch(()=>{ne||ce(!0)}),()=>{ne=!0}},[v]);const q=my(v,K,be),J=I.useMemo(()=>ff(K),[K]),oe=t1(D,_)!==t1(w.request,A),he=C==="advanced",Se=r==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",T=r==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",z=ne=>{E(ne),Qh("density",ne==="advanced"?"advanced":void 0)},me=()=>f?.({request:D,scripts:Sn(_),serverUrl:j,requestTab:M,scriptTab:Y});return p.jsxs("div",{className:"space-y-3","data-try-it-session":!0,children:[q&&p.jsx(yf,{message:"FlexDoc could not save environment changes to browser storage. They will be lost when the page is closed.",showCapabilities:!1,warning:!0,theme:r,label:"API Client storage status"}),p.jsxs("div",{className:`flex flex-wrap items-center justify-between gap-3 rounded-lg border p-2 ${Se}`,children:[p.jsxs("div",{className:"flex rounded-md border p-1",role:"group","aria-label":"Try It density",children:[p.jsx("button",{type:"button","aria-pressed":!he,className:`rounded px-3 py-1.5 text-sm ${he?"":"bg-blue-600 text-white"}`,onClick:()=>z("basic"),children:ge?.tryItBasic||"Basic"}),p.jsx("button",{type:"button","aria-pressed":he,className:`rounded px-3 py-1.5 text-sm ${he?"bg-blue-600 text-white":""}`,onClick:()=>z("advanced"),children:ge?.tryItAdvanced||"Advanced"})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[he&&oe&&p.jsx("span",{"aria-label":"Unsaved Try It changes",className:"text-xs font-medium",children:ge?.unsavedChanges||"Unsaved changes"}),f&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-1.5 text-sm",onClick:me,children:[p.jsx(Nd,{className:"h-4 w-4"}),ge?.openApiClient||"Open in API Client"]})]})]}),he&&p.jsx("div",{className:`rounded-lg border p-3 ${Se}`,children:p.jsxs("label",{className:"flex flex-wrap items-center gap-2 text-sm font-medium",children:[p.jsx("span",{children:ge?.environment||"Environment"}),p.jsxs("select",{"aria-label":ge?.environment||"Try It environment",className:`min-w-48 rounded-md border px-2 py-1.5 text-sm ${T}`,value:K.activeEnvironmentId||"",onChange:ne=>ee(Ce=>({...Ce,activeEnvironmentId:ne.target.value||void 0})),children:[p.jsx("option",{value:"",children:ge?.noEnvironment||"No environment"}),K.environments.map(ne=>p.jsx("option",{value:ne.id,children:ne.name},ne.id))]})]})}),p.jsx(e1,{initialRequest:w.request,initialScripts:A,initialRequestTab:M,initialScriptTab:Y,density:C,theme:r,messages:ge,credentials:s?.tryIt?.credentials||"same-origin",requestInterceptor:s?.tryIt?.requestInterceptor,hostExecution:s?.tryIt?.hostExecution,credentialStorage:K.credentialStorage||"remember",onCredentialStorageChange:ne=>ee(Ce=>({...Ce,credentialStorage:ne})),environmentVariables:J,serverOptions:b,initialServerUrl:w.serverUrl,onServerUrlChange:R,onRequestChange:u,onDraftChange:O,onScriptsChange:ne=>L(Sn(ne)),onRequestTabChange:ne=>{G(ne),Qh("tab",ne)},onScriptTabChange:ne=>{B(ne),Qh("script",ne)},onEnvironmentChanges:ne=>ee(Ce=>hf(Ce,ne))})]})};function Wh(t,e){const n=encodeURIComponent(t).replace(/%/g,"~");return`${e.trim().toLowerCase()}-${n}`}function k3(t,e){return`${e.trim().toLowerCase()}-${t.replace(/[^a-zA-Z0-9]+/g,"-").replace(/^-|-$/g,"")}`}const C3=["curl","javascript","python","go","java"];function N3(){if(typeof window>"u")return{tryIt:!1};const t=new URLSearchParams(window.location.search),e=t.get("tab"),n=t.get("script");return{tryIt:t.get("tryIt")==="1",requestTab:e&&/^(params|headers|authorization|body|scripts)$/.test(e)?e:void 0,scriptTab:n&&/^(pre-request|tests)$/.test(n)?n:void 0}}function T3(t,e){if(typeof window>"u")return;const n=new URL(window.location.href);e?n.searchParams.set(t,e):n.searchParams.delete(t),window.history.replaceState(null,"",`${n.pathname}${n.search}${n.hash}`)}const j3=({spec:t,path:e,method:n,theme:r="light",options:s={},defaultExpandedSections:a,runtimeSnapshot:c,onOpenInApiClient:u})=>{const f=N3(),h=a??tf(s.expand,s.expand===void 0?s.expandResponses:void 0),g=f.tryIt&&!h.includes("tryIt")?[...h,"tryIt"]:h,b=`${n}:${e}:${g.join("|")}`,[v,w]=I.useState(()=>({key:b,sections:new Set(g)})),A=v.key===b?v.sections:new Set(g),[C,E]=I.useState(s.codeSamples?.languages?.[0]||"curl"),[D,O]=I.useState(!1),j=I.useId().replace(/:/g,""),R=I.useRef({}),L=t.paths[e]?.[n.toLowerCase()],M=I.useMemo(()=>L?B0(t,e,n,q0(t,e,n)):void 0,[L,t,e,n]),G=`${n}:${e}`,[Y,B]=I.useState(()=>({key:G,request:M})),K=Y.key===G?Y.request:M,ee=re=>{B({key:G,request:re})},be=I.useMemo(()=>L?Rk(t,e,n):[],[L,t,e,n]),ce=s.messages;if(I.useEffect(()=>{!f.tryIt||typeof document>"u"||requestAnimationFrame(()=>document.getElementById("tryIt-heading")?.scrollIntoView({block:"start"}))},[f.tryIt,n,e]),!L)return c?.runtimeOnly?.some(ve=>ve.path===e&&ve.method.toUpperCase()===n.toUpperCase())||c?.validation?.findings.some(ve=>ve.code==="runtime.operation-undocumented"&&ve.location.path===e&&ve.location.method?.toUpperCase()===n.toUpperCase())?p.jsxs("div",{className:"p-6",children:[p.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3",children:[p.jsx("span",{className:"rounded-md bg-blue-600 px-3 py-1 text-sm font-bold text-white",children:n.toUpperCase()}),p.jsx("code",{className:"break-all text-lg font-semibold",children:e})]}),p.jsx("p",{className:`text-sm ${r==="dark"?"text-gray-300":"text-gray-700"}`,children:ce?.runtimeRouteUndocumented||"The running service registers this operation. OpenAPI does not document it."})]}):p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});if(!K)return p.jsx("div",{className:"p-6",children:ce?.operationNotFound||"Operation not found."});const ge=r==="dark"?"text-gray-400":"text-gray-600",q=r==="dark"?"border-gray-700 bg-gray-800/60":"border-gray-200 bg-white",J=r==="dark"?"bg-gray-900 text-gray-100":"bg-white text-gray-900",oe=s.codeSamples?.languages?.length?s.codeSamples.languages:C3,he=L.security??t.security,Se={requiredPropsFirst:s.requiredPropsFirst,sortPropsAlphabetically:s.sortPropsAlphabetically},T=r==="dark"?"bg-blue-950/60 text-blue-200":"bg-blue-100 text-blue-700",z=r==="dark"?"bg-red-950/60 text-red-200":"bg-red-100 text-red-700",me=r==="dark"?"bg-orange-950/60 text-orange-200":"bg-orange-100 text-orange-700",ne=r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700",Ce=re=>`${j}-code-tab-${re}`,Re=`${j}-code-panel`,qe=re=>{const ve=!A.has(re);w(Ne=>{const $e=new Set(Ne.key===b?Ne.sections:g);return $e.has(re)?$e.delete(re):$e.add(re),{key:b,sections:$e}}),re==="tryIt"&&T3("tryIt",ve?"1":void 0)},He=(re,ve,Ne)=>p.jsxs("section",{className:"mb-8","aria-labelledby":`${ve}-heading`,children:[p.jsxs("button",{type:"button",id:`${ve}-heading`,"aria-expanded":A.has(ve),onClick:()=>qe(ve),className:"mb-4 flex min-h-10 w-full items-center gap-2 text-left text-base font-semibold sm:text-lg",children:[A.has(ve)?p.jsx(Bg,{className:"h-5 w-5 shrink-0"}):p.jsx($g,{className:"h-5 w-5 shrink-0"}),re]}),A.has(ve)&&Ne]}),Je=re=>{E(re),R.current[re]?.focus()},Be=(re,ve)=>{if(!/^(ArrowLeft|ArrowRight|Home|End)$/.test(re.key))return;re.preventDefault();const Ne=oe.indexOf(ve),$e=re.key==="Home"?oe[0]:re.key==="End"?oe[oe.length-1]:re.key==="ArrowRight"?oe[(Ne+1)%oe.length]:oe[(Ne-1+oe.length)%oe.length];Je($e)},dt=async()=>{if(typeof window>"u"||typeof navigator>"u"||!navigator.clipboard)return;const re=new URL(window.location.href);re.hash=Wh(e,n),await navigator.clipboard.writeText(re.toString()),O(!0),window.setTimeout(()=>O(!1),1400)},At=L.requestBody?In.isReference(L.requestBody)?In.resolveReference(t,L.requestBody.$ref):L.requestBody:void 0,yt=Object.entries(L).filter(([re])=>re.startsWith("x-")),Ge=typeof s.theme=="object"?s.theme.methodColors?.[n.toLowerCase()]:void 0,Q=c?.routes.some(re=>re.method===n.toUpperCase()&&re.path===e);return p.jsx("div",{lang:s.locale,className:`min-h-full ${J}`,children:p.jsxs("article",{className:"mx-auto w-full max-w-6xl p-4 sm:p-6 lg:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex min-w-0 flex-wrap items-center gap-2 sm:gap-3",children:[p.jsx("span",{className:`shrink-0 rounded border px-2.5 py-1 text-xs font-bold sm:text-sm ${In.getMethodColor(n,r)}`,style:{background:Ge?.bg,borderColor:Ge?.border},children:n.toUpperCase()}),p.jsx("code",{className:`min-w-0 max-w-full overflow-x-auto rounded px-2.5 py-1 font-mono text-sm sm:text-base ${r==="dark"?"bg-gray-800 text-blue-300":"bg-gray-100 text-gray-900"}`,children:e}),p.jsxs("button",{type:"button",className:"inline-flex min-h-9 items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs","aria-label":"Copy endpoint link",onClick:()=>{dt()},children:[D?p.jsx(qg,{className:"h-3.5 w-3.5"}):p.jsx(XA,{className:"h-3.5 w-3.5"}),D?"Copied":"Copy link"]})]}),L.summary&&p.jsx("h1",{className:"mb-2 text-2xl font-bold tracking-tight sm:text-3xl",children:L.summary}),L.description&&p.jsx("p",{className:`max-w-3xl whitespace-pre-wrap leading-relaxed ${ge}`,children:L.description}),p.jsxs("div",{className:"mt-4 flex flex-wrap gap-3 text-sm",children:[L.deprecated&&p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-orange-300":"inline-flex items-center gap-1 text-orange-600",children:[p.jsx(Ad,{className:"h-4 w-4"}),"Deprecated"]}),he?.length?p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-red-300":"inline-flex items-center gap-1 text-red-600",children:[p.jsx(WA,{className:"h-4 w-4"}),"Authentication required"]}):p.jsxs("span",{className:r==="dark"?"inline-flex items-center gap-1 text-green-300":"inline-flex items-center gap-1 text-green-600",children:[p.jsx(QA,{className:"h-4 w-4"}),"No authentication required"]}),c&&(Q?p.jsx("span",{className:r==="dark"?"text-green-300":"text-green-600",children:"Observed at runtime"}):p.jsx("span",{className:c.discoveryComplete?r==="dark"?"text-amber-300":"text-amber-600":ge,children:c.discoveryComplete?"Not found at runtime":"Not observed in partial runtime discovery"})),L.operationId&&p.jsxs("span",{className:ge,children:["operationId: ",p.jsx("code",{children:L.operationId})]})]}),(s.showExtensions||s.showCommonExtensions)&&yt.length>0&&p.jsx("div",{className:`mt-4 rounded-lg border p-3 text-xs ${q}`,children:yt.map(([re,ve])=>p.jsxs("div",{children:[p.jsx("code",{children:re}),": ",typeof ve=="string"?ve:JSON.stringify(ve)]},re))})]}),be.length>0&&He(ce?.parameters||"Parameters","parameters",p.jsx("div",{className:"space-y-3",children:be.map(re=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:"font-medium",children:re.name}),p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${T}`,children:re.in}),re.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"}),re.deprecated&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${me}`,children:"deprecated"})]}),re.description&&p.jsx("p",{className:`mb-3 text-sm ${ge}`,children:re.description}),re.schema&&p.jsx(Dr,{spec:t,schema:re.schema,theme:r,required:re.required,...Se})]},`${re.in}:${re.name}`))})),At&&He(ce?.requestBody||"Request Body","requestBody",p.jsxs("div",{className:"space-y-4",children:[At.description&&p.jsx("p",{className:ge,children:At.description}),Object.entries(At.content||{}).map(([re,ve])=>p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("code",{className:`rounded px-2 py-1 text-xs ${ne}`,children:re}),At.required&&p.jsx("span",{className:`rounded px-2 py-0.5 text-xs ${z}`,children:"required"})]}),ve.schema&&p.jsx(Dr,{spec:t,schema:ve.schema,theme:r,...Se}),ve.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(ve.example,null,2),language:"json",title:"Example payload",theme:r,wrap:!0})})]},re))]})),He(ce?.responses||"Responses","responses",p.jsx("div",{className:"space-y-4",children:Object.entries(L.responses||{}).map(([re,ve])=>{const Ne=In.isReference(ve)?In.resolveReference(t,ve.$ref):ve;return p.jsxs("div",{className:`rounded-lg border p-4 ${q}`,children:[p.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[p.jsx("span",{className:"rounded border px-2.5 py-1 text-sm font-bold",children:re}),p.jsx("span",{className:`text-sm ${ge}`,children:Ne.description})]}),Ne.headers&&s.showRequestHeaders&&p.jsxs("div",{className:"mb-3 text-sm",children:[p.jsx("span",{className:"font-medium",children:"Headers:"})," ",Object.keys(Ne.headers).join(", ")]}),Ne.content&&Object.entries(Ne.content).map(([$e,We])=>{const vt=We.examples&&Object.values(We.examples)[s.payloadSampleIdx||0];return p.jsxs("div",{className:"mt-3",children:[p.jsx("code",{className:`rounded px-1.5 py-0.5 text-xs ${ne}`,children:$e}),We.schema&&p.jsx("div",{className:"mt-2",children:p.jsx(Dr,{spec:t,schema:We.schema,theme:r,...Se})}),We.example!==void 0&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(We.example,null,2),language:"json",title:"Example response",theme:r,wrap:!0})}),vt&&p.jsx("div",{className:"mt-3",children:p.jsx(Rr,{code:JSON.stringify(vt.value??vt,null,2),language:"json",title:"Example response",theme:r,wrap:!0})})]},$e)})]},re)})})),s.tryIt?.enabled!==!1&&He(ce?.tryIt||"Try It","tryIt",p.jsx(A3,{spec:t,path:e,method:n,theme:r,options:s,initialRequestTab:f.requestTab,initialScriptTab:f.scriptTab,onRequestChange:ee,onOpenInApiClient:u},`${n}:${e}:${s.tryIt?.defaultServer||""}`)),s.codeSamples?.enabled!==!1&&He(ce?.codeExamples||"Code Examples","codeSamples",p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"mb-3 flex max-w-full gap-1 overflow-x-auto pb-1",role:"tablist","aria-label":"Code example language",children:oe.map(re=>p.jsx("button",{ref:ve=>{R.current[re]=ve},id:Ce(re),type:"button",role:"tab","aria-controls":Re,"aria-selected":C===re,tabIndex:C===re?0:-1,onClick:()=>Je(re),onKeyDown:ve=>Be(ve,re),className:`shrink-0 rounded-md px-3 py-2 text-sm ${C===re?"bg-blue-600 text-white":r==="dark"?"bg-gray-800 text-gray-200":"bg-gray-100 text-gray-700"}`,children:$0(re)},re))}),p.jsx("div",{role:"tabpanel",id:Re,"aria-labelledby":Ce(C),children:p.jsx(Rr,{code:Lk(K,C),language:C==="curl"?"bash":C,title:$0(C),theme:r,wrap:!!(typeof s.theme=="object"&&s.theme.typography?.code?.wrap)})})]})),L.externalDocs&&p.jsx("p",{className:"pb-4 text-sm",children:p.jsx("a",{className:"text-blue-600 underline",href:L.externalDocs.url,target:"_blank",rel:"noopener noreferrer",children:L.externalDocs.description||"External documentation"})})]})})};function E3(t){const e=t?.["x-flexdoc-priority"]??t?.["x-flexdoc-weight"];return typeof e=="number"&&Number.isFinite(e)?e:0}function O3(t,e){let n=E3(t)*1e3;return t?.["x-flexdoc-highlight"]===!0&&(n+=1e5),t?.deprecated||(n+=100),t?.summary&&(n+=40),t?.description&&(n+=20),t?.operationId&&(n+=10),Array.isArray(t?.tags)&&t.tags.length>0&&(n+=5),e.toLowerCase()==="get"?n+=3:e.toLowerCase()==="post"&&(n+=2),n}function M3(t){let e=0;const n=[];for(const[r,s]of Object.entries(t.paths))for(const a of In.getHttpMethods(s)){const c=s[a];n.push({path:r,method:a,operation:c,score:O3(c,a),order:e++})}return n.sort((r,s)=>s.score-r.score||r.order-s.order).slice(0,6)}const R3=({spec:t,onEndpointSelect:e,theme:n="light"})=>{const r=n==="dark",s=r?"border-gray-700 bg-gray-800 text-white shadow-lg":"border-gray-200 bg-white text-gray-900 shadow-sm",a=r?"text-gray-300":"text-gray-600",c=r?"hover:border-gray-600 hover:bg-gray-700":"hover:border-blue-300 hover:bg-blue-50",u=Object.values(t.paths).reduce((g,b)=>{for(const v of In.getHttpMethods(b))g[v]=(g[v]||0)+1,g.total+=1;return g},{total:0}),f=M3(t),h=[{icon:Ig,title:"Total endpoints",value:u.total,surface:r?"bg-blue-900":"bg-blue-100",iconClass:r?"text-blue-300":"text-blue-600"},{icon:zg,title:"Servers",value:t.servers?.length||0,surface:r?"bg-green-900":"bg-green-100",iconClass:r?"text-green-300":"text-green-600"},{icon:Vg,title:"Tags",value:t.tags?.length||0,surface:r?"bg-purple-900":"bg-purple-100",iconClass:r?"text-purple-300":"text-purple-600"},{icon:ik,title:"Security schemes",value:t.components?.securitySchemes?Object.keys(t.components.securitySchemes).length:0,surface:r?"bg-orange-900":"bg-orange-100",iconClass:r?"text-orange-300":"text-orange-600"}];return p.jsx("div",{className:`flex-1 overflow-y-auto ${r?"bg-gray-900":"bg-gray-50"}`,children:p.jsxs("div",{className:"p-4 md:p-8",children:[p.jsxs("header",{className:"mb-8",children:[p.jsxs("div",{className:"mb-4 flex items-center gap-4",children:[p.jsx("div",{className:`flex h-12 w-12 items-center justify-center rounded-xl ${r?"bg-blue-700":"bg-gradient-to-br from-blue-500 to-blue-600"}`,children:p.jsx(Ig,{className:"h-6 w-6 text-white"})}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("h1",{className:`truncate text-2xl font-bold md:text-3xl ${r?"text-white":"text-gray-900"}`,children:t.info.title}),p.jsxs("p",{className:a,children:["Version ",t.info.version]})]})]}),t.info.description&&p.jsx("p",{className:`max-w-4xl text-lg leading-relaxed ${a}`,children:t.info.description})]}),p.jsx("div",{className:"mb-8 grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",children:h.map(({icon:g,title:b,value:v,surface:w,iconClass:A})=>p.jsx("div",{className:`rounded-xl border p-4 ${s}`,children:p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("div",{className:`flex h-10 w-10 items-center justify-center rounded-lg ${w}`,children:p.jsx(g,{className:`h-5 w-5 ${A}`})}),p.jsxs("div",{children:[p.jsx("p",{className:`text-sm font-medium ${a}`,children:b}),p.jsx("p",{className:"text-xl font-bold",children:v})]})]})},b))}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"method-distribution-heading",children:[p.jsx("h2",{id:"method-distribution-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"HTTP method distribution"}),p.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-4 lg:grid-cols-6",children:["get","post","put","delete","patch","options"].map(g=>p.jsxs("div",{className:"text-center",children:[p.jsx("div",{className:`mx-auto mb-2 flex items-center justify-center rounded-lg px-3 py-1.5 ${In.getMethodColor(g,n)}`,children:p.jsx("span",{className:"text-sm font-medium",children:g.toUpperCase()})}),p.jsx("p",{className:"font-bold",children:u[g]||0})]},g))})]}),p.jsxs("section",{className:`mb-8 rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"endpoint-highlights-heading",children:[p.jsxs("div",{className:"mb-4",children:[p.jsx("h2",{id:"endpoint-highlights-heading",className:"text-lg font-semibold md:text-xl",children:"Endpoint highlights"}),p.jsx("p",{className:`mt-1 text-xs ${a}`,children:"Prioritized by explicit FlexDoc metadata when supplied, then by documentation completeness. This is not usage analytics."})]}),p.jsxs("div",{className:"space-y-3",children:[f.map(({path:g,method:b,operation:v})=>p.jsxs("button",{type:"button",onClick:()=>e(g,b),className:`w-full rounded-lg border p-3 text-left transition-colors ${c} ${r?"border-gray-700":"border-gray-200"}`,children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsx("span",{className:`rounded border px-2 py-1 text-xs font-bold ${In.getMethodColor(b,n)}`,children:b.toUpperCase()}),p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g})]}),v?.summary&&p.jsx("p",{className:`ml-14 mt-2 text-sm ${a}`,children:v.summary})]},`${b}-${g}`)),f.length===0&&p.jsx("p",{className:`py-4 text-sm ${a}`,children:"No operations are defined in this specification."})]})]}),p.jsxs("div",{className:"grid grid-cols-1 gap-6 lg:grid-cols-2",children:[(t.info.contact||t.info.license)&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-information-heading",children:[p.jsx("h2",{id:"api-information-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Information"}),p.jsxs("div",{className:"space-y-4",children:[t.info.contact&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"Contact"}),t.info.contact.name&&p.jsx("p",{className:`text-sm ${a}`,children:t.info.contact.name}),t.info.contact.email&&p.jsx("a",{className:`block text-sm underline ${r?"text-blue-300":"text-blue-600"}`,href:`mailto:${t.info.contact.email}`,children:t.info.contact.email}),t.info.contact.url&&p.jsxs("a",{href:t.info.contact.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:["Website ",p.jsx(Nd,{className:"h-3 w-3"})]})]}),t.info.license&&p.jsxs("div",{children:[p.jsx("h3",{className:"mb-2 font-medium",children:"License"}),t.info.license.url?p.jsxs("a",{href:t.info.license.url,target:"_blank",rel:"noopener noreferrer",className:`inline-flex items-center gap-1 text-sm ${r?"text-blue-300":"text-blue-600"}`,children:[t.info.license.name,p.jsx(Nd,{className:"h-3 w-3"})]}):p.jsx("p",{className:`text-sm ${a}`,children:t.info.license.name})]})]})]}),t.servers&&t.servers.length>0&&p.jsxs("section",{className:`rounded-xl border p-4 md:p-6 ${s}`,"aria-labelledby":"api-servers-heading",children:[p.jsx("h2",{id:"api-servers-heading",className:"mb-4 text-lg font-semibold md:text-xl",children:"Servers"}),p.jsx("div",{className:"space-y-3",children:t.servers.map((g,b)=>p.jsxs("div",{className:`rounded-lg p-3 ${r?"bg-gray-700/50":"bg-gray-50"}`,children:[p.jsx("code",{className:`break-all font-mono text-sm ${r?"text-blue-300":"text-blue-600"}`,children:g.url}),g.description&&p.jsx("p",{className:`mt-1 text-sm ${a}`,children:g.description})]},`${g.url}:${b}`))})]})]})]})})};var n1={commit:"unknown"};const D3=typeof n1>"u"?{commit:"unknown"}:n1,_3=({footerClasses:t,footer:e})=>{const n=e?.copyright,r=e?.link||[],s=D3,a=e?.showBuildInfo!==!1&&s.commit!=="unknown";return p.jsx("footer",{className:`${t} w-full border-t`,children:p.jsxs("div",{className:"mx-auto flex min-h-12 w-full max-w-[1600px] flex-col gap-2 px-4 py-3 text-xs sm:flex-row sm:items-center sm:justify-between sm:px-6 sm:text-sm",children:[p.jsxs("p",{children:[n||p.jsxs(p.Fragment,{children:["Powered by ",p.jsx("a",{href:"https://flexdoc.prauga.com",target:"_blank",rel:"noopener noreferrer",className:"font-semibold hover:opacity-80 transition-opacity",children:"FlexDoc"})]}),a]}),r.length>0&&p.jsx("nav",{"aria-label":"Footer links",className:"flex flex-wrap gap-x-4 gap-y-2",children:r.map(c=>p.jsx("a",{href:c.url,target:"_blank",rel:"noopener noreferrer",className:"hover:opacity-80",children:c.text},`${c.text}:${c.url}`))})]})})},L3=(t,e,n)=>t==="dark"?n:e,q3="Runtime intelligence returned an invalid snapshot.",B3=new Set(["runtime.operation-undocumented","runtime.operation-unobserved","runtime.method-mismatch","runtime.duplicate-operation"]),$3=new Set(["error","warning","info"]),I3=new Set(["pass","warn","fail","partial"]);function an(){throw new Error(q3)}function Ji(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function Un(t,e){const n=t[e];return(typeof n!="string"||n.trim()==="")&&an(),n}function Zh(t,e){const n=t[e];if(n!==void 0)return(typeof n!="string"||n.trim()==="")&&an(),n}function i1(t,e){const n=t[e];if(n!==void 0){if(typeof n=="string"&&n.trim()!=="")return n;if(Array.isArray(n)&&n.length>0&&n.every(r=>typeof r=="string"&&r.trim()!==""))return[...n];an()}}function cr(t,e){const n=t[e];return(typeof n!="number"||!Number.isInteger(n)||n<0)&&an(),n}function H3(t){return Ji(t)||an(),{method:Un(t,"method"),path:Un(t,"path")}}function ep(t){return Array.isArray(t)||an(),t.map(H3)}function z3(t){(!Ji(t)||!Ji(t.location))&&an();const e=Un(t,"code"),n=Un(t,"severity");(!B3.has(e)||!$3.has(n)||t.location.kind!=="operation")&&an();const r={id:Un(t,"id"),code:e,severity:n,location:{kind:"operation",path:Un(t.location,"path")},message:Un(t,"message")},s=Zh(t.location,"method");s&&(r.location.method=s);const a=i1(t,"expected");a!==void 0&&(r.expected=a);const c=i1(t,"observed");return c!==void 0&&(r.observed=c),r}function U3(t){(!Ji(t)||!Ji(t.summary)||!Array.isArray(t.findings)||typeof t.complete!="boolean")&&an();const e=Un(t,"status");I3.has(e)||an();const n=t.findings.map(z3),r={total:cr(t.summary,"total"),errors:cr(t.summary,"errors"),warnings:cr(t.summary,"warnings"),info:cr(t.summary,"info")},s={total:n.length,errors:n.filter(c=>c.severity==="error").length,warnings:n.filter(c=>c.severity==="warning").length,info:n.filter(c=>c.severity==="info").length};JSON.stringify(r)!==JSON.stringify(s)&&an();const a=r.errors>0?"fail":r.warnings>0?"warn":t.complete?"pass":"partial";return e!==a&&an(),{status:e,complete:t.complete,findings:n,summary:r}}function V3(t){Ji(t)||an(),(!Ji(t.runtime)||!Ji(t.summary))&&an(),typeof t.discoveryComplete!="boolean"&&an();const e={name:Un(t.runtime,"name"),version:Un(t.runtime,"version"),platform:Un(t.runtime,"platform"),arch:Un(t.runtime,"arch")},n={documented:cr(t.summary,"documented"),runtime:cr(t.summary,"runtime"),matched:cr(t.summary,"matched"),runtimeOnly:cr(t.summary,"runtimeOnly"),documentedOnly:cr(t.summary,"documentedOnly")},r={framework:Un(t,"framework"),runtime:e,discoveryComplete:t.discoveryComplete,routes:ep(t.routes),runtimeOnly:ep(t.runtimeOnly),documentedOnly:ep(t.documentedOnly),summary:n},s=Zh(t,"frameworkVersion");s&&(r.frameworkVersion=s);const a=Zh(t,"serverOrigin");if(a&&(r.serverOrigin=a),t.server!==void 0){Ji(t.server)||an();const c=t.server.localPort;c!==void 0&&(typeof c!="number"||!Number.isInteger(c)||c<=0||c>65535)&&an(),r.server=c===void 0?{}:{localPort:c}}return t.environment!==void 0&&(Ji(t.environment)||an(),r.environment={name:Un(t.environment,"name")}),t.validation!==void 0&&(r.validation=U3(t.validation)),r}const F3=60;function P3(t,e,n=F3){const r=Math.max(0,Math.min(Math.max(0,e-20),Math.max(0,t-n)));return{start:r,end:Math.min(t,r+n)}}const tp=44;function Y3(t){return Array.from(t.querySelectorAll('button:not([disabled]), input:not([disabled]), [tabindex]:not([tabindex="-1"])'))}const K3=({spec:t,theme:e,onEndpointSelect:n,onHome:r,onOpenSettings:s,onOpenApiClient:a,onOpenRuntime:c,onSendCurrent:u,messages:f})=>{const[h,g]=I.useState(!1),[b,v]=I.useState(""),[w,A]=I.useState(0),C=I.useRef(null),E=I.useRef(null),D=I.useRef([]),O=h&&typeof document<"u"&&Array.from(document.querySelectorAll('[data-api-client-send="true"]')).some(be=>!be.closest(".hidden")),j=I.useMemo(()=>{const be=[{id:"overview",label:f?.openOverview||"Open Overview",action:r},{id:"api-client",label:f?.openApiClient||"Open API Client",action:a},...c?[{id:"runtime",label:f?.openRuntime||"Open Runtime Intelligence",action:c}]:[],{id:"settings",label:f?.openSettings||"Open Viewer Settings",action:s},...u&&O?[{id:"send-current",label:f?.sendCurrentRequest||"Send current request",action:u}]:[]];for(const[ce,ge]of Object.entries(t.paths))for(const q of In.getHttpMethods(ge))be.push({id:`operation:${q}:${ce}`,label:`${q.toUpperCase()} ${ce}`,action:()=>n(ce,q)});return be},[O,f?.openApiClient,f?.openOverview,f?.openRuntime,f?.openSettings,f?.sendCurrentRequest,n,r,a,c,s,u,t]),R=b.trim().toLowerCase(),_=I.useMemo(()=>R?j.filter(be=>be.label.toLowerCase().includes(R)):j,[j,R]),{start:L,end:M}=P3(_.length,w),G=_.slice(L,M),Y=I.useCallback(()=>{g(!1),v(""),A(0)},[]),B=I.useCallback(be=>{be&&(Y(),be.action())},[Y]);if(I.useEffect(()=>{const be=ce=>{!(ce.ctrlKey||ce.metaKey)||ce.key.toLowerCase()!=="k"||(ce.preventDefault(),g(ge=>!ge))};return document.addEventListener("keydown",be),()=>document.removeEventListener("keydown",be)},[]),I.useEffect(()=>{if(!h||typeof document>"u")return;const be=document.activeElement instanceof HTMLElement?document.activeElement:null,ce=document.body.style.overflow;document.body.style.overflow="hidden",requestAnimationFrame(()=>E.current?.focus());const ge=q=>{if(q.key==="Escape"){q.preventDefault(),Y();return}if(q.key==="ArrowDown"||q.key==="ArrowUp"||q.key==="Home"||q.key==="End"){q.preventDefault(),A(T=>!_.length||q.key==="Home"?0:q.key==="End"?_.length-1:q.key==="ArrowDown"?(T+1)%_.length:(T-1+_.length)%_.length);return}if(q.key==="Enter"){q.preventDefault(),B(_[w]);return}if(q.key!=="Tab"||!C.current)return;const J=Y3(C.current);if(!J.length)return;const oe=J[0],he=J[J.length-1],Se=document.activeElement;q.shiftKey&&(Se===oe||!C.current.contains(Se))?(q.preventDefault(),he.focus()):!q.shiftKey&&(Se===he||!C.current.contains(Se))&&(q.preventDefault(),oe.focus())};return document.addEventListener("keydown",ge),()=>{document.body.style.overflow=ce,document.removeEventListener("keydown",ge),be?.isConnected&&be.focus()}},[w,B,Y,h,_]),I.useEffect(()=>{D.current[w]?.scrollIntoView({block:"nearest"})},[w]),!h)return null;const K=e==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",ee=e==="dark"?"bg-blue-950/70 text-blue-100":"bg-blue-50 text-blue-900";return p.jsxs("div",{className:"fixed inset-0 z-[80]",children:[p.jsx("button",{type:"button","aria-label":f?.closeCommandPalette||"Close command palette",className:"absolute inset-0 bg-black/40",onClick:Y}),p.jsxs("div",{ref:C,role:"dialog","aria-modal":"true","aria-label":f?.commandPalette||"Command palette",className:`relative mx-auto mt-[10vh] w-[min(94vw,56rem)] overflow-hidden rounded-xl border shadow-2xl ${K}`,children:[p.jsx("input",{ref:E,"aria-label":f?.searchCommands||"Search commands",className:"w-full border-b bg-transparent p-3 text-sm outline-none",placeholder:f?.searchCommandsPlaceholder||"Search operations and commands…",value:b,onChange:be=>{v(be.target.value),A(0)}}),p.jsxs("div",{className:"max-h-[60vh] overflow-y-auto p-2",role:"listbox","aria-label":f?.commandResults||"Command results",children:[L>0&&p.jsx("div",{"aria-hidden":"true",style:{height:L*tp}}),G.map((be,ce)=>{const ge=L+ce;return p.jsx("button",{ref:q=>{D.current[ge]=q},type:"button",role:"option","aria-selected":ge===w,"aria-posinset":ge+1,"aria-setsize":_.length,className:`w-full rounded-md p-2 text-left text-sm ${ge===w?ee:""}`,style:{height:tp,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},onMouseEnter:()=>A(ge),onClick:()=>B(be),children:be.label},be.id)}),M<_.length&&p.jsx("div",{"aria-hidden":"true",style:{height:(_.length-M)*tp}}),!_.length&&p.jsx("div",{className:"p-3 text-sm opacity-65",children:f?.noCommandResults||"No matching commands."})]})]})]})},G3={parameters:"Parameters",requestBody:"Request body",responses:"Responses",tryIt:"Try It",codeSamples:"Code examples"};function X3(t){return t===void 0?"host":Array.isArray(t)?"custom":t==="none"?"minimal":t}function J3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Q3=({open:t,theme:e,hostTheme:n,manageTheme:r,viewerTheme:s,viewerExpand:a,effectiveExpandedSections:c,messages:u,onThemeChange:f,onExpandChange:h,onClose:g})=>{const b=I.useRef(null),v=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const D=document.activeElement instanceof HTMLElement?document.activeElement:null;v.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),g();return}if(j.key!=="Tab"||!b.current)return;const R=J3(b.current);if(R.length===0){j.preventDefault(),b.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!b.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!b.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.removeEventListener("keydown",O),D?.isConnected&&D.focus()}},[t,g]),!t)return null;const w=e==="dark",A=w?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",C=w?"border-gray-700 bg-gray-800 text-gray-100":"border-gray-300 bg-white text-gray-900",E=Array.isArray(a)?a.filter(D=>Cs.includes(D)):[];return p.jsxs("div",{className:"fixed inset-0 z-[70]",children:[p.jsx("button",{type:"button","aria-label":"Close settings backdrop",className:"absolute inset-0 bg-black/40",onClick:g}),p.jsxs("aside",{ref:b,role:"dialog","aria-modal":"true","aria-label":"Viewer settings",tabIndex:-1,className:`absolute inset-y-0 right-0 flex w-[min(92vw,24rem)] flex-col border-l shadow-2xl ${A}`,children:[p.jsxs("div",{className:"flex min-h-14 items-center justify-between border-b px-4",children:[p.jsxs("div",{children:[p.jsx("div",{className:"font-semibold",children:"Settings"}),p.jsx("div",{className:"text-xs opacity-65",children:"Preferences are saved for this documentation."})]}),p.jsx("button",{type:"button","aria-label":"Close settings",className:"inline-flex h-11 w-11 items-center justify-center rounded-md",onClick:g,children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-4",children:[r&&p.jsxs("section",{"aria-labelledby":"appearance-settings-heading",children:[p.jsx("h2",{id:"appearance-settings-heading",className:"mb-1 text-sm font-semibold",children:u?.viewerTheme||"Appearance"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"Override the documentation host theme on this device."}),p.jsxs("select",{"aria-label":u?.viewerTheme||"Viewer theme",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:s||"host",onChange:D=>f(D.target.value==="host"?void 0:D.target.value),children:[p.jsxs("option",{value:"host",children:["Use documentation default (",n,")"]}),p.jsx("option",{value:"light",children:u?.lightTheme||"Light"}),p.jsx("option",{value:"dark",children:u?.darkTheme||"Dark"}),p.jsx("option",{value:"high-contrast",children:u?.highContrast||"High contrast"})]})]}),p.jsxs("section",{"aria-labelledby":"expansion-settings-heading",children:[p.jsx("h2",{id:"expansion-settings-heading",className:"mb-1 text-sm font-semibold",children:"Default expanded sections"}),p.jsx("p",{className:"mb-3 text-xs opacity-65",children:"This preference overrides the documentation author's default. Opening or closing a section manually remains temporary."}),p.jsxs("select",{ref:v,"aria-label":"Default expanded sections",className:`w-full rounded-md border px-3 py-2 text-sm ${C}`,value:X3(a),onChange:D=>{const O=D.target.value;h(O==="host"?void 0:O==="custom"?[...c]:O)},children:[p.jsx("option",{value:"host",children:"Use documentation default"}),p.jsx("option",{value:"minimal",children:"Minimal"}),p.jsx("option",{value:"documentation",children:"Documentation"}),p.jsx("option",{value:"interactive",children:"Interactive"}),p.jsx("option",{value:"all",children:"All sections"}),p.jsx("option",{value:"custom",children:"Custom sections"})]}),Array.isArray(a)&&p.jsxs("fieldset",{className:"mt-4 space-y-2",children:[p.jsx("legend",{className:"mb-2 text-xs font-medium uppercase tracking-wide opacity-65",children:"Custom sections"}),Cs.map(D=>p.jsxs("label",{className:"flex min-h-9 items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E.includes(D),onChange:O=>{const j=new Set(E);O.target.checked?j.add(D):j.delete(D),h(Cs.filter(R=>j.has(R)))}}),G3[D]]},D))]}),a!==void 0&&p.jsx("button",{type:"button",className:"mt-5 rounded-md border px-3 py-2 text-sm",onClick:()=>h(void 0),children:"Reset to documentation defaults"})]})]})]})]})};function W3(t){return Array.from(t.querySelectorAll('button:not([disabled]), select:not([disabled]), input:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(e=>e.getAttribute("aria-hidden")!=="true")}const Z3=({open:t,theme:e,loading:n,error:r,snapshot:s,onClose:a,onEndpointSelect:c,messages:u})=>{const f=I.useRef(null),h=I.useRef(null);if(I.useEffect(()=>{if(!t||typeof document>"u")return;const E=document.activeElement instanceof HTMLElement?document.activeElement:null,D=document.body.style.overflow;document.body.style.overflow="hidden",h.current?.focus();const O=j=>{if(j.key==="Escape"){j.preventDefault(),a();return}if(j.key!=="Tab"||!f.current)return;const R=W3(f.current);if(R.length===0){j.preventDefault(),f.current.focus();return}const _=R[0],L=R[R.length-1],M=document.activeElement;j.shiftKey&&(M===_||!f.current.contains(M))?(j.preventDefault(),L.focus()):!j.shiftKey&&(M===L||!f.current.contains(M))&&(j.preventDefault(),_.focus())};return document.addEventListener("keydown",O),()=>{document.body.style.overflow=D,document.removeEventListener("keydown",O),E?.isConnected&&E.focus()}},[t,a]),!t)return null;const g=e==="dark",b=g?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",v=g?"text-gray-400":"text-gray-600",w=g?"border-red-800 bg-red-950/50 text-red-200":"border-red-300 bg-red-50 text-red-800",A=g?"border-amber-700 bg-amber-950/50 text-amber-200":"border-amber-300 bg-amber-50 text-amber-900",C=g?"text-green-300":"text-green-700";return p.jsxs("div",{className:"fixed inset-0 z-50",children:[p.jsx("button",{tabIndex:-1,className:"absolute inset-0 bg-black/40","aria-label":u?.closeRuntimeIntelligence||"Close runtime intelligence",onClick:a}),p.jsxs("section",{ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"runtime-intelligence-heading",tabIndex:-1,className:`absolute inset-y-0 right-0 w-[min(92vw,32rem)] overflow-y-auto border-l p-5 shadow-2xl ${b}`,children:[p.jsxs("div",{className:"mb-5 flex items-start justify-between gap-4",children:[p.jsxs("div",{children:[p.jsxs("div",{id:"runtime-intelligence-heading",className:"flex items-center gap-2 text-lg font-semibold",children:[p.jsx(Lg,{className:"h-5 w-5"}),u?.runtimeIntelligence||"Runtime intelligence"]}),p.jsx("p",{className:`mt-1 text-sm ${v}`,children:u?.runtimeIntelligenceDescription||"Live route presence and backend context from the service hosting this documentation."})]}),p.jsx("button",{ref:h,className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":u?.closeRuntimeIntelligencePanel||"Close runtime intelligence panel",onClick:a,children:p.jsx(Od,{className:"h-4 w-4"})})]}),n&&p.jsx("p",{className:v,children:u?.inspectingRuntimeRoutes||"Inspecting runtime routes…"}),r&&p.jsx("div",{role:"alert",className:`rounded-lg border p-3 text-sm ${w}`,children:r}),s&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-3 text-sm",children:[p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.framework||"Framework"}),p.jsxs("div",{className:"font-semibold",children:[s.framework,s.frameworkVersion?` ${s.frameworkVersion}`:""]})]}),p.jsxs("div",{className:"rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.matched||"Matched"}),p.jsxs("div",{className:"font-semibold",children:[s.summary.matched," / ",s.summary.documented]})]}),p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtime||"Runtime"}),p.jsxs("div",{className:"font-semibold",children:[s.runtime.name," ",s.runtime.version]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.runtime.platform," · ",s.runtime.arch]})]}),s.validation&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.contractValidation||"Contract validation"}),p.jsxs("div",{className:"font-semibold",children:[s.validation.status.toUpperCase()," · ",s.validation.summary.total," ",s.validation.summary.total===1?"finding":"findings"]}),p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[s.validation.summary.errors," errors · ",s.validation.summary.warnings," warnings · ",s.validation.summary.info," info"]})]}),(s.serverOrigin||s.server?.localPort)&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.runtimeServer||"Runtime server"}),s.serverOrigin&&p.jsx("code",{className:"block break-all text-xs",children:s.serverOrigin}),s.server?.localPort&&p.jsxs("div",{className:`mt-1 text-xs ${v}`,children:[u?.backendListenerPort||"Backend listener port"," ",s.server.localPort]})]}),s.environment?.name&&p.jsxs("div",{className:"col-span-2 rounded-lg border p-3",children:[p.jsx("div",{className:v,children:u?.environment||"Environment"}),p.jsx("div",{className:"font-semibold",children:s.environment.name})]})]}),!s.discoveryComplete&&p.jsxs("div",{className:`flex gap-2 rounded-lg border p-3 text-sm ${A}`,children:[p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),u?.routeDiscoveryPartial||"Route discovery is partial; documented routes not observed at runtime may be false positives."]}),s.validation?p.jsx(eM,{result:s.validation,theme:e,messages:u,onSelect:c?E=>{E.location.method&&(c(E.location.path,E.location.method),a())}:void 0}):p.jsxs(p.Fragment,{children:[p.jsx(s1,{title:u?.implementedButUndocumented||"Implemented but undocumented",routes:s.runtimeOnly,empty:u?.noUndocumentedRuntimeRoutes||"No undocumented runtime routes discovered.",theme:e,warning:!0,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0}),p.jsx(s1,{title:u?.documentedButNotObserved||"Documented but not observed",routes:s.documentedOnly,empty:u?.everyDocumentedRouteObserved||"Every documented route was observed.",theme:e,openLabel:u?.openRuntimeRoute||"Open runtime route",onSelect:c?E=>{c(E.path,E.method),a()}:void 0})]}),s.validation?.status==="pass"&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.contractValidationPass||"The running backend matches the OpenAPI contract for all validated checks."]}),!s.validation&&s.summary.runtimeOnly===0&&s.summary.documentedOnly===0&&s.discoveryComplete&&p.jsxs("div",{className:`flex items-center gap-2 text-sm ${C}`,children:[p.jsx(oa,{className:"h-4 w-4"}),u?.runtimeAligned||"Runtime routes and OpenAPI paths are aligned."]})]})]})]})};function eM({result:t,theme:e,messages:n,onSelect:r}){const a=e==="dark"?"text-gray-400":"text-gray-600",c=n?.contractValidation||"Contract validation";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[c," ",p.jsxs("span",{className:a,children:["(",t.findings.length,")"]})]}),t.findings.length?p.jsx("div",{className:"space-y-2",children:t.findings.map(u=>{const f=u.code==="runtime.operation-unobserved"||u.code==="runtime.method-mismatch",h=u.code==="runtime.operation-undocumented",g=!!(r&&u.location.method&&(f||h)),b=h?n?.openRuntimeRoute||"Open runtime route":n?.openDocumentedOperation||"Open documented operation",v=p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"flex gap-2 text-sm",children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:u.severity.toUpperCase()}),p.jsx("code",{className:"break-all",children:u.code})]}),p.jsx("div",{className:`mt-1 text-xs ${a}`,children:u.message}),(u.expected!==void 0||u.observed!==void 0)&&p.jsxs("div",{className:`mt-1 text-xs ${a}`,children:[u.expected!==void 0&&p.jsxs("div",{children:[n?.validationExpected||"Expected",": ",r1(u.expected)]}),u.observed!==void 0&&p.jsxs("div",{children:[n?.validationObserved||"Observed",": ",r1(u.observed)]})]})]});return g?p.jsx("button",{type:"button","aria-label":`${b} ${u.location.method} ${u.location.path}`,className:"w-full rounded border p-2 text-left",onClick:()=>r?.(u),children:v},u.id):p.jsx("div",{className:"rounded border p-2",children:v},u.id)})}):p.jsx("p",{className:`text-sm ${a}`,children:n?.contractValidationPass||"No contract mismatches detected."})]})}function r1(t){return Array.isArray(t)?t.join(", "):t}function s1({title:t,routes:e,empty:n,theme:r,warning:s=!1,onSelect:a,openLabel:c="Open runtime route"}){const u=r==="dark",f=u?"text-gray-400":"text-gray-600",h=s?u?"border-amber-700":"border-amber-300":"";return p.jsxs("section",{children:[p.jsxs("h3",{className:"mb-2 font-semibold",children:[t," ",p.jsxs("span",{className:f,children:["(",e.length,")"]})]}),e.length?p.jsx("div",{className:"space-y-2",children:e.map(g=>a?p.jsxs("button",{type:"button","aria-label":`${c} ${g.method} ${g.path}`,className:`flex w-full gap-2 rounded border p-2 text-left text-sm transition hover:border-blue-500 hover:bg-blue-500/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 ${h}`,onClick:()=>a(g),children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`):p.jsxs("div",{className:`flex gap-2 rounded border p-2 text-sm ${h}`,children:[p.jsx("span",{className:"w-14 shrink-0 font-semibold",children:g.method}),p.jsx("code",{className:"break-all",children:g.path})]},`${g.method}:${g.path}`))}):p.jsx("p",{className:`text-sm ${f}`,children:n})]})}function tM({className:t="h-8 w-8"}){return p.jsxs("svg",{"aria-hidden":"true",viewBox:"0 0 512 512",className:t,children:[p.jsx("rect",{width:"512",height:"512",rx:"115",fill:"white"}),p.jsx("path",{d:"M397 130.546C397 136.784 392.409 141.84 386.745 141.84H196.951C191.287 141.84 186.696 146.896 186.696 153.134L186.692 239.516C186.692 245.754 191.283 250.811 196.947 250.811H315.049C320.712 250.811 325.303 255.867 325.303 262.105V317.357C325.303 323.594 320.712 328.651 315.049 328.651H196.951C191.288 328.651 186.696 333.707 186.696 339.944L186.692 436.706C186.692 442.944 182.101 448 176.438 448H125.255C119.591 448 115 442.943 115 436.706V329.566C115 323.329 119.591 318.272 125.255 318.272H171.66C177.324 318.272 181.915 313.216 181.915 306.978V272.483C181.915 266.246 177.324 261.189 171.66 261.189H125.255C119.591 261.189 115 256.133 115 249.895V142.756C115 136.518 119.591 131.461 125.255 131.461H171.66C177.324 131.461 181.915 126.405 181.915 120.167V75.2941C181.915 69.0565 186.506 64 192.169 64H386.745C392.409 64 397 69.0565 397 75.2941V130.546Z",fill:"#3461E1"})]})}const np="flexdoc-runner",ip=1;function Qc(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function Wc(t){return Array.isArray(t)?`[${t.map(Wc).join(",")}]`:Qc(t)?`{${Object.keys(t).filter(n=>t[n]!==void 0).sort().map(n=>`${JSON.stringify(n)}:${Wc(t[n])}`).join(",")}}`:JSON.stringify(t)}function l1(t){return t.type==="oauth2"?{...t,scopes:t.scopes?[...t.scopes]:void 0}:{...t}}function nM(t){return{...t,auth:l1(t.auth),variables:t.variables.map(e=>({...e}))}}function rp(t){return{...t,auth:l1(t.auth)}}function a1(t){if(t.request.binary?.file)throw new Error(`Request ${t.name} contains an in-memory binary file. Runner artifact file payload export is not supported yet.`);if((t.request.formData||[]).some(e=>e.type==="file"&&!!e.file))throw new Error(`Request ${t.name} contains an in-memory multipart file. Runner artifact file payload export is not supported yet.`)}function sp(t){a1(t);const e=Ei(t.request);return e.binary&&delete e.binary.file,e.formData&&(e.formData=e.formData.map(n=>{const r={...n};return delete r.file,r})),{...t,request:e,scripts:t.scripts?Sn(t.scripts):void 0}}function iM(t){return{...t,variables:t.variables.map(e=>({...e}))}}function o1(t,e){const n=t.collections.find(r=>r.id===e.collectionId);if(!n)throw new Error(`Runner scope references missing collection ${e.collectionId}.`);return n}function c1(t,e,n){const r=new Set,s=new Map(t.folders.filter(c=>c.collectionId===e).map(c=>[c.id,c]));let a=n?s.get(n):void 0;for(;a&&!r.has(a.id);)r.add(a.id),a=a.parentFolderId?s.get(a.parentFolderId):void 0;return r}function u1(t,e,n){const r=new Set([n]);let s=!0;for(;s;){s=!1;for(const a of t.folders)a.collectionId!==e||!a.parentFolderId||r.has(a.id)||r.has(a.parentFolderId)&&(r.add(a.id),s=!0)}return r}function d1(t,e){if(e.type==="collection")return t.folders.filter(s=>s.collectionId===e.collectionId).map(rp);if(e.type==="folder"){if(!t.folders.find(c=>c.id===e.folderId&&c.collectionId===e.collectionId))throw new Error(`Runner scope references missing folder ${e.folderId}.`);const a=u1(t,e.collectionId,e.folderId);for(const c of c1(t,e.collectionId,e.folderId))a.add(c);return t.folders.filter(c=>c.collectionId===e.collectionId&&a.has(c.id)).map(rp)}const n=t.requests.find(s=>s.id===e.requestId&&s.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);const r=c1(t,e.collectionId,n.folderId);return t.folders.filter(s=>s.collectionId===e.collectionId&&r.has(s.id)).map(rp)}function f1(t,e){if(e.type==="collection")return t.requests.filter(r=>r.collectionId===e.collectionId).map(sp);if(e.type==="folder"){const r=u1(t,e.collectionId,e.folderId);return t.requests.filter(s=>s.collectionId===e.collectionId&&!!s.folderId&&r.has(s.folderId)).map(sp)}const n=t.requests.find(r=>r.id===e.requestId&&r.collectionId===e.collectionId);if(!n)throw new Error(`Runner scope references missing request ${e.requestId}.`);return[sp(n)]}function h1(t,e){if(t.length===0)throw new Error(`Runner ${e.type} scope contains no executable saved requests.`)}function rM(t,e){const n=e===!1?void 0:e??t.activeEnvironmentId;if(!n)return{environments:[]};const r=t.environments.find(s=>s.id===n);if(!r){if(typeof e=="string")throw new Error(`Runner export references missing environment ${e}.`);return{environments:[]}}return{environments:[iM(r)],activeEnvironmentId:r.id}}function sM(t,e,n={}){const r=t.credentialStorage!==void 0&&t.credentialStorage!=="remember"?Z0(t):t,s=o1(r,e),a=f1(r,e);h1(a,e);const c=rM(r,n.environmentId),u={version:6,collections:[nM(s)],folders:d1(r,e),requests:a,environments:c.environments,...c.activeEnvironmentId?{activeEnvironmentId:c.activeEnvironmentId}:{},history:[]};return{kind:np,version:ip,exportedAt:n.exportedAt||new Date().toISOString(),scope:{...e},workspace:u}}function lM(t){if(!Qc(t)||typeof t.type!="string"||typeof t.collectionId!="string"||!t.collectionId)throw new Error("Invalid FlexDoc Runner artifact scope.");if(t.type==="collection")return{type:"collection",collectionId:t.collectionId};if(t.type==="folder"&&typeof t.folderId=="string"&&t.folderId)return{type:"folder",collectionId:t.collectionId,folderId:t.folderId};if(t.type==="request"&&typeof t.requestId=="string"&&t.requestId)return{type:"request",collectionId:t.collectionId,requestId:t.requestId};throw new Error("Invalid FlexDoc Runner artifact scope.")}function Zc(t,e){const n=t.map(r=>r.id);if(new Set(n).size!==n.length)throw new Error(`Runner artifact workspace contains duplicate ${e} ids.`)}function p1(t,e){return t.length===e.length&&t.every((n,r)=>n.id===e[r]?.id)}function aM(t,e){const n=o1(t,e);if(t.collections.length!==1||t.collections[0].id!==n.id)throw new Error("Runner artifact workspace must contain exactly the scoped collection.");if(t.environments.length>1)throw new Error("Runner artifact workspace may contain at most one selected environment.");if(t.environments.length===0&&t.activeEnvironmentId!==void 0)throw new Error("Runner artifact workspace cannot select an environment that is not embedded.");if(t.environments.length===1&&t.activeEnvironmentId!==t.environments[0].id)throw new Error("Runner artifact workspace must activate its single embedded environment.");if(e.type==="folder"&&!t.folders.some(a=>a.id===e.folderId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing folder ${e.folderId}.`);if(e.type==="request"&&!t.requests.some(a=>a.id===e.requestId&&a.collectionId===e.collectionId))throw new Error(`Runner artifact references missing request ${e.requestId}.`);const r=d1(t,e),s=f1(t,e);if(h1(s,e),!p1(t.folders,r)||!p1(t.requests,s))throw new Error(`Runner artifact workspace contains entities outside its declared ${e.type} scope.`)}function oM(t){if(t.version!==6||!Array.isArray(t.collections)||!Array.isArray(t.folders)||!Array.isArray(t.requests)||!Array.isArray(t.environments)||!Array.isArray(t.history)||t.history.length!==0||t.activeEnvironmentId!==void 0&&typeof t.activeEnvironmentId!="string")throw new Error("Invalid FlexDoc Runner artifact workspace. Expected canonical workspace version 6 with empty history.");return{version:6,collections:t.collections,folders:t.folders,requests:t.requests,environments:t.environments,...t.activeEnvironmentId!==void 0?{activeEnvironmentId:t.activeEnvironmentId}:{},history:[]}}function cM(t){if(!Qc(t)||t.kind!==np||t.version!==ip||typeof t.exportedAt!="string"||!t.exportedAt.trim()||!Qc(t.workspace))throw new Error("Invalid FlexDoc Runner artifact. Expected flexdoc-runner version 1.");const e=lM(t.scope),n=oM(t.workspace),r=ay(n);if(Wc(n)!==Wc(r))throw new Error("Invalid FlexDoc Runner artifact workspace. Portable artifacts must not require workspace migration or normalization repairs.");Zc(r.collections,"collection"),Zc(r.folders,"folder"),Zc(r.requests,"request"),Zc(r.environments,"environment"),aM(r,e);for(const s of r.requests)a1(s);return{kind:np,version:ip,exportedAt:t.exportedAt,scope:e,workspace:r}}function uM(t){return`${JSON.stringify(cM(t),null,2)} +`}function dM(t,e,n){if(!n)return null;const r=t.folders.find(c=>c.id===n&&c.collectionId===e);if(!r)return new Set;const s=new Set([r.id]);let a=!0;for(;a;){a=!1;for(const c of t.folders)c.collectionId!==e||!c.parentFolderId||s.has(c.id)||s.has(c.parentFolderId)&&(s.add(c.id),a=!0)}return s}function Sl(t,e,n){const r=dM(t,e,n);return t.requests.filter(s=>s.collectionId!==e?!1:r?!!s.folderId&&r.has(s.folderId):!0)}function fM(t,e){const n=new Map(t.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")}function m1(t,e,n){const r=t.collections.find(a=>a.id===e)?.name||"Deleted collection";if(!n)return r;const s=fM(t.folders.filter(a=>a.collectionId===e),n);return s?`${r} / ${s}`:`${r} / Deleted folder`}function hM(t){return!t.error&&!t.scriptError&&t.scriptTests.every(e=>e.passed)}async function pM(t){const e=Sl(t.workspace,t.collectionId,t.folderId),n=t.runId||An("run"),r=t.runName||m1(t.workspace,t.collectionId,t.folderId);let s=t.workspace;const a=[];let c=t.signal?.aborted===!0;for(let g=0;gcy(s,b.collectionId,b.folderId,_||{type:"none"}),variables:C,collectionVariables:v,externalVariables:t.externalVariables,environmentVariables:A,signal:t.signal,fetcher:t.fetcher,now:t.now,onCollectionChanges:_=>{s=dy(s,b.collectionId,_),t.onCollectionChanges?.(_)},onEnvironmentChanges:_=>{s=hf(s,_),t.onEnvironmentChanges?.(_)}}),D=t.signal?.aborted===!0,O=!D&&hM(E);let j;E.result&&!D&&(s=oy(s,{...E.result,collectionId:b.collectionId,folderId:b.folderId,runId:n,runName:r,runIndex:g+1,runTotal:e.length,runPassed:O}),j=s.history[0]?.id);const R={requestId:b.id,requestName:b.name,collectionId:b.collectionId,folderId:b.folderId,passed:O,cancelled:D,historyEntryId:j,outcome:E};if(a.push(R),t.onRequestComplete?.(R,g,e.length),D){c=!0;break}if(!R.passed&&t.stopOnFailure&&gg.passed).length,f=a.filter(g=>g.cancelled).length,h=a.filter(g=>!g.passed&&!g.cancelled).length;return{runId:n,runName:r,collectionId:t.collectionId,folderId:t.folderId,total:e.length,completed:a.length,passed:u,failed:h,cancelled:f,stopped:c,items:a,workspace:s}}function Gr(){return new Date().toISOString()}function mM(t){return`${t.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"runner"}.flexdoc.json`}const gM=({request:t,scripts:e,onLoadRequest:n,onSelectedCollectionChange:r,onSelectedFolderChange:s,onRunCollection:a,onRunFolder:c,selectedCollectionId:u,selectedFolderId:f="",workspace:h,onWorkspaceChange:g,hostExecution:b,theme:v})=>{const[w,A]=I.useState(""),[C,E]=I.useState(""),[D,O]=I.useState(""),[j,R]=I.useState(null),[_,L]=I.useState(""),M=h.collections.find(Q=>Q.id===u)||h.collections[0],G=I.useMemo(()=>h.folders.filter(Q=>Q.collectionId===M?.id),[M?.id,h.folders]),Y=I.useMemo(()=>h.requests.filter(Q=>Q.collectionId===M?.id),[M?.id,h.requests]),B=G.find(Q=>Q.id===f),K=I.useMemo(()=>new Map(G.map(Q=>[Q.id,Q])),[G]),ee=I.useMemo(()=>{const Q=[],re=new Set,ve=(Ne,$e)=>{G.filter(We=>We.parentFolderId===Ne).forEach(We=>{re.has(We.id)||(re.add(We.id),Q.push({folder:We,depth:$e}),ve(We.id,$e+1))})};return ve(void 0,0),G.forEach(Ne=>{re.has(Ne.id)||(re.add(Ne.id),Q.push({folder:Ne,depth:0}),ve(Ne.id,1))}),Q},[G]),be=Q=>{const re=[],ve=new Set;let Ne=K.get(Q);for(;Ne&&!ve.has(Ne.id);)ve.add(Ne.id),re.unshift(Ne.name),Ne=Ne.parentFolderId?K.get(Ne.parentFolderId):void 0;return re.join(" / ")};I.useEffect(()=>{r?.(M?.id)},[r,M?.id]);const ce=(Q,re)=>{try{const ve=sM(h,Q),Ne=new Blob([uM(ve)],{type:"application/json;charset=utf-8"}),$e=URL.createObjectURL(Ne),We=document.createElement("a");We.href=$e,We.download=mM(re),We.click(),setTimeout(()=>URL.revokeObjectURL($e),0),L("")}catch(ve){L(ve instanceof Error?ve.message:String(ve))}},ge=()=>{const Q=w.trim();if(!Q)return;const re=Gr(),ve=An("collection");g(Ne=>({...Ne,collections:[...Ne.collections,{id:ve,name:Q,auth:{type:"none"},variables:[],createdAt:re,updatedAt:re}]})),r?.(ve),s?.(""),A(""),R(null)},q=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},J=Q=>{if(!B)return;const re=Gr();g(ve=>({...ve,folders:ve.folders.map(Ne=>Ne.id===B.id?{...Ne,auth:Q,updatedAt:re}:Ne)}))},oe=()=>{if(!M)return;const Q=Gr();g(re=>({...re,collections:re.collections.map(ve=>ve.id===M.id?{...ve,variables:[...ve.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:Q}:ve)}))},he=(Q,re)=>{if(!M)return;const ve=Gr();g(Ne=>({...Ne,collections:Ne.collections.map($e=>$e.id===M.id?{...$e,variables:$e.variables.map(We=>We.id===Q?{...We,...re}:We),updatedAt:ve}:$e)}))},Se=Q=>{if(!M)return;const re=Gr();g(ve=>({...ve,collections:ve.collections.map(Ne=>Ne.id===M.id?{...Ne,variables:Ne.variables.filter($e=>$e.id!==Q),updatedAt:re}:Ne)}))},T=()=>{const Q=C.trim();if(!Q||!M)return;const re=Gr(),ve=An("folder");g(Ne=>({...Ne,folders:[...Ne.folders,{id:ve,collectionId:M.id,parentFolderId:f||void 0,name:Q,auth:{type:"inherit"},createdAt:re,updatedAt:re}]})),s?.(ve),E("")},z=()=>{if(!M)return;const Q=D.trim()||t.url||"Untitled request",re=Gr();if(j){g(Ne=>({...Ne,requests:Ne.requests.map($e=>$e.id===j?{...$e,collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),updatedAt:re}:$e)}));return}const ve={id:An("request"),collectionId:M.id,folderId:f||void 0,name:Q,request:Ei(t),scripts:Sn(e),createdAt:re,updatedAt:re};g(Ne=>({...Ne,requests:[...Ne.requests,ve]})),R(ve.id),O(Q)},me=Q=>{const re=h.requests.find(ve=>ve.id===Q);re&&(R(re.id),r?.(re.collectionId),s?.(re.folderId||""),O(re.name),n(Ei(re.request),re.scripts?Sn(re.scripts):void 0,re.collectionId,re.folderId))},ne=Q=>{g(re=>({...re,requests:re.requests.filter(ve=>ve.id!==Q)})),j===Q&&(R(null),O(""))},Ce=Q=>{const re=h.folders.find(ve=>ve.id===Q);g(ve=>LC(ve,Q)),f===Q&&s?.(re?.parentFolderId||"")},Re=Q=>{const re=qC(h,Q);g(re),u===Q&&(r?.(re.collections[0]?.id||""),s?.(""),R(null),O(""))},qe=v==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",He=v==="dark"?"text-gray-400":"text-gray-500",Je=v==="dark"?"bg-blue-500/10 text-blue-300":"bg-blue-500/10 text-blue-700",Be=Q=>p.jsxs("div",{className:`group flex items-center gap-1 rounded-md ${j===Q.id?"bg-blue-500/10":""}`,children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm hover:bg-blue-500/10","aria-label":`Load saved request ${Q.name}`,onClick:()=>me(Q.id),children:[p.jsx("span",{className:"mr-2 font-mono text-xs font-semibold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"truncate",children:Q.name})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Export saved request ${Q.name} for Runner`,onClick:()=>ce({type:"request",collectionId:Q.collectionId,requestId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete saved request ${Q.name}`,onClick:()=>ne(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id),dt=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=be(Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return p.jsxs(Sd.Fragment,{children:[p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button","aria-label":`Select folder ${$e}`,className:`min-w-0 flex-1 rounded-md py-2 pr-2 text-left text-sm ${f===Q.id?"bg-blue-500/10":""}`,style:{paddingLeft:`${8+re*16}px`},onClick:()=>s?.(Q.id),children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Run folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>c?.(Q.collectionId,Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.collectionId,Q.id).length===0,"aria-label":`Export folder ${$e} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"folder",collectionId:Q.collectionId,folderId:Q.id},$e),children:p.jsx(Cd,{className:"h-4 w-4"})}),p.jsx("button",{type:"button","aria-label":`Delete folder ${$e}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Ce(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]}),We.map(vt=>dt(vt,re+1,Ne))]},Q.id)},At=(Q,re,ve=new Set)=>{if(ve.has(Q.id))return null;const Ne=new Set(ve);Ne.add(Q.id);const $e=Y.filter(vt=>vt.folderId===Q.id),We=G.filter(vt=>vt.parentFolderId===Q.id);return $e.length===0&&We.length===0?null:p.jsxs("div",{className:"space-y-1",children:[$e.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("div",{className:`mb-1 text-xs font-semibold uppercase tracking-wide ${He}`,style:{paddingLeft:`${8+re*12}px`},children:Q.name}),p.jsx("div",{style:{paddingLeft:`${re*12}px`},children:$e.map(Be)})]}),We.map(vt=>At(vt,re+1,Ne))]},Q.id)},yt=G.filter(Q=>!Q.parentFolderId),Ge=f?be(f):"";return p.jsxs("section",{className:"space-y-4","aria-labelledby":"api-client-collections-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(GA,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-collections-heading",className:"font-semibold",children:"Collections"})]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New collection name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:w,onChange:Q=>A(Q.target.value),placeholder:"New collection"}),p.jsx("button",{type:"button","aria-label":"Add collection",className:"rounded-md border px-3 py-2",onClick:ge,children:p.jsx(ks,{className:"h-4 w-4"})})]}),p.jsx("div",{className:"space-y-2",children:h.collections.map(Q=>p.jsxs("div",{className:"flex items-center gap-1",children:[p.jsx("button",{type:"button",className:`min-w-0 flex-1 rounded-md px-2 py-2 text-left text-sm font-medium ${Q.id===M?.id?Je:""}`,onClick:()=>{r?.(Q.id),s?.(""),R(null),O("")},children:Q.name}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Run collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>a?.(Q.id),children:p.jsx(ca,{className:"h-4 w-4"})}),p.jsx("button",{type:"button",disabled:Sl(h,Q.id).length===0,"aria-label":`Export collection ${Q.name} for Runner`,className:"rounded-md p-2 opacity-70 hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-30",onClick:()=>ce({type:"collection",collectionId:Q.id},Q.name),children:p.jsx(Cd,{className:"h-4 w-4"})}),h.collections.length>1&&p.jsx("button",{type:"button","aria-label":`Delete collection ${Q.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>Re(Q.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},Q.id))}),p.jsxs("p",{className:`text-xs ${He}`,children:["Runner exports can include saved authentication, collection variables, and the active environment. Treat downloaded ",p.jsx("code",{children:".flexdoc.json"})," files as sensitive configuration."]}),_&&p.jsx("p",{role:"alert",className:"text-xs text-red-600",children:_}),M&&p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection authorization"}),p.jsx(bf,{auth:M.auth,label:"Collection",hostExecution:b,onChange:q,theme:v}),p.jsx("p",{className:`text-xs ${He}`,children:"Requests set to inherit use the nearest folder override, then this collection authorization."})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Collection variables"}),p.jsxs("button",{type:"button","aria-label":"Add collection variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:oe,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[M.variables.map((Q,re)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Collection variable ${re+1} enabled`,type:"checkbox",checked:Q.enabled!==!1,onChange:ve=>he(Q.id,{enabled:ve.target.checked})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"baseUrl",value:Q.key,onChange:ve=>he(Q.id,{key:ve.target.value})}),p.jsx("input",{"aria-label":`Collection variable ${re+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${qe}`,placeholder:"https://api.example.com",value:Q.value,onChange:ve=>he(Q.id,{value:ve.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove collection variable ${re+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>Se(Q.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},Q.id)),M.variables.length===0&&p.jsxs("p",{className:`text-xs ${He}`,children:["Collection variables provide reusable defaults such as ",p.jsx("code",{children:"{{baseUrl}}"}),". Active environment values override matching collection keys."]})]})]}),p.jsxs("div",{className:"space-y-1 border-t pt-3",children:[p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New folder name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${qe}`,value:C,onChange:Q=>E(Q.target.value),placeholder:"Folder"}),p.jsx("button",{type:"button","aria-label":"Add folder",className:"rounded-md border px-3 py-2",onClick:T,children:p.jsx(YA,{className:"h-4 w-4"})})]}),p.jsx("p",{className:`text-xs ${He}`,children:Ge?`New folders are created inside ${Ge}.`:"New folders are created at the collection root."})]}),p.jsxs("div",{className:"space-y-1",children:[p.jsx("button",{type:"button","aria-label":"Select collection root",className:`w-full rounded-md px-2 py-2 text-left text-sm ${f===""?"bg-blue-500/10":""}`,onClick:()=>s?.(""),children:"Unfiled / collection root"}),yt.map(Q=>dt(Q,0))]}),B&&p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsxs("div",{className:"text-xs font-semibold uppercase tracking-wide",children:["Folder authorization — ",Ge]}),p.jsx(bf,{auth:B.auth,label:"Folder",allowInherit:!0,hostExecution:b,onChange:J,theme:v})]}),p.jsxs("div",{className:"space-y-2 border-t pt-3",children:[p.jsx("input",{"aria-label":"Saved request name",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:D,onChange:Q=>O(Q.target.value),placeholder:"Request name"}),p.jsxs("select",{"aria-label":"Saved request folder",className:`w-full rounded-md border px-2 py-2 text-sm ${qe}`,value:f,onChange:Q=>s?.(Q.target.value),children:[p.jsx("option",{value:"",children:"Unfiled"}),ee.map(({folder:Q,depth:re})=>p.jsx("option",{value:Q.id,children:`${"— ".repeat(re)}${Q.name}`},Q.id))]}),p.jsxs("button",{type:"button",className:"inline-flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium",onClick:z,children:[p.jsx(tk,{className:"h-4 w-4"})," ",j?"Update request":"Save request"]})]}),p.jsxs("div",{className:"space-y-3 border-t pt-3",children:[Y.filter(Q=>!Q.folderId).map(Be),yt.map(Q=>At(Q,0)),Y.length===0&&p.jsx("p",{className:`px-2 text-xs ${He}`,children:"Save the current request to build a reusable collection."})]})]})]})};function za(){return new Date().toISOString()}const yM=({workspace:t,onWorkspaceChange:e,theme:n})=>{const[r,s]=I.useState(""),a=t.environments.find(w=>w.id===t.activeEnvironmentId),c=n==="dark"?"bg-gray-900 border-gray-700 text-gray-100":"bg-white border-gray-300 text-gray-900",u=n==="dark"?"text-gray-400":"text-gray-500",f=()=>{const w=r.trim();if(!w)return;const A=za(),C=An("environment");e(E=>({...E,environments:[...E.environments,{id:C,name:w,variables:[],createdAt:A,updatedAt:A}],activeEnvironmentId:C})),s("")},h=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,name:w,updatedAt:A}:E)}))},g=()=>{if(!a)return;const w=za();e(A=>({...A,environments:A.environments.map(C=>C.id===a.id?{...C,variables:[...C.variables,{id:An("variable"),key:"",value:"",enabled:!0}],updatedAt:w}:C)}))},b=(w,A)=>{if(!a)return;const C=za();e(E=>({...E,environments:E.environments.map(D=>D.id===a.id?{...D,variables:D.variables.map(O=>O.id===w?{...O,...A}:O),updatedAt:C}:D)}))},v=w=>{if(!a)return;const A=za();e(C=>({...C,environments:C.environments.map(E=>E.id===a.id?{...E,variables:E.variables.filter(D=>D.id!==w),updatedAt:A}:E)}))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-environment-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{id:"api-client-environment-heading",className:"font-semibold",children:"Environment"}),a&&p.jsx("button",{type:"button","aria-label":`Delete environment ${a.name}`,className:"rounded-md p-2 opacity-70 hover:opacity-100",onClick:()=>e(w=>_C(w,a.id)),children:p.jsx(fi,{className:"h-4 w-4"})})]}),p.jsxs("select",{"aria-label":"Active environment",className:`w-full rounded-md border px-2 py-2 text-sm ${c}`,value:t.activeEnvironmentId||"",onChange:w=>e(A=>({...A,activeEnvironmentId:w.target.value||void 0})),children:[p.jsx("option",{value:"",children:"No environment"}),t.environments.map(w=>p.jsx("option",{value:w.id,children:w.name},w.id))]}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx("input",{"aria-label":"New environment name",className:`min-w-0 flex-1 rounded-md border px-2 py-2 text-sm ${c}`,value:r,onChange:w=>s(w.target.value),placeholder:"New environment"}),p.jsx("button",{type:"button","aria-label":"Add environment",className:"rounded-md border px-3 py-2",onClick:f,children:p.jsx(ks,{className:"h-4 w-4"})})]}),a&&p.jsxs("div",{className:"space-y-3",children:[p.jsx("input",{"aria-label":"Environment name",className:`w-full rounded-md border px-2 py-2 text-sm font-medium ${c}`,value:a.name,onChange:w=>h(w.target.value)}),p.jsxs("div",{className:"flex items-center justify-between",children:[p.jsx("span",{className:"text-xs font-semibold uppercase tracking-wide",children:"Variables"}),p.jsxs("button",{type:"button","aria-label":"Add environment variable",className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs",onClick:g,children:[p.jsx(ks,{className:"h-3.5 w-3.5"})," Add"]})]}),p.jsxs("div",{className:"space-y-2",children:[a.variables.map((w,A)=>p.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_minmax(0,1fr)_auto] items-center gap-1",children:[p.jsx("input",{"aria-label":`Environment variable ${A+1} enabled`,type:"checkbox",checked:w.enabled!==!1,onChange:C=>b(w.id,{enabled:C.target.checked})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} key`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"baseUrl",value:w.key,onChange:C=>b(w.id,{key:C.target.value})}),p.jsx("input",{"aria-label":`Environment variable ${A+1} value`,className:`min-w-0 rounded-md border px-2 py-1.5 font-mono text-xs ${c}`,placeholder:"https://api.example.com",value:w.value,onChange:C=>b(w.id,{value:C.target.value})}),p.jsx("button",{type:"button","aria-label":`Remove environment variable ${A+1}`,className:"rounded-md p-1.5 opacity-70 hover:opacity-100",onClick:()=>v(w.id),children:p.jsx(fi,{className:"h-3.5 w-3.5"})})]},w.id)),a.variables.length===0&&p.jsxs("p",{className:`text-xs ${u}`,children:["Add variables such as ",p.jsx("code",{children:"{{baseUrl}}"})," or ",p.jsx("code",{children:"{{token}}"}),"."]})]})]})]})};function eu(t){return!!t.error||!!t.scriptError||t.status!==void 0&&t.status>=400||!!t.scriptTests?.some(e=>!e.passed)}function lp(t){const e=new Date(t);return Number.isNaN(e.getTime())?t:e.toLocaleString()}function bM(t,e){const n=e.query.trim().toLowerCase();return t.history.filter(r=>{const s=r.collectionId?t.collections.find(g=>g.id===r.collectionId)?.name||"Deleted collection":"",a=r.folderId?t.folders.find(g=>g.id===r.folderId)?.name||"Deleted folder":"",c=!n||[r.executedMethod,r.resolvedUrl,r.status,r.statusText,s,a,r.runName].filter(g=>g!==void 0).some(g=>String(g).toLowerCase().includes(n)),u=e.method==="all"||r.executedMethod.toUpperCase()===e.method,f=eu(r),h=e.outcome==="all"||e.outcome==="success"&&!f||e.outcome==="failed"&&f||e.outcome==="tests"&&!!r.scriptTests?.length;return c&&u&&h})}function xM(t){const e=new Set,n=[];for(const r of t){if(!r.runId){n.push({kind:"entry",entry:r});continue}if(e.has(r.runId))continue;e.add(r.runId);const s=t.filter(c=>c.runId===r.runId).sort((c,u)=>(c.runIndex||Number.MAX_SAFE_INTEGER)-(u.runIndex||Number.MAX_SAFE_INTEGER)),a=Math.max(s.length,...s.map(c=>c.runTotal||0));n.push({kind:"run",group:{runId:r.runId,runName:r.runName||"Collection run",entries:s,total:a,captured:s.length,passed:s.filter(c=>c.runPassed===!0).length,failed:s.filter(c=>c.runPassed===!1).length,cancelled:0}})}return n}const vM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onViewAll:r,theme:s})=>{const a=s==="dark"?"text-gray-400":"text-gray-500",[c,u]=Sd.useState(!1),f=async()=>{if(!(typeof navigator>"u"||!navigator.clipboard?.writeText))try{await navigator.clipboard.writeText(JSON.stringify(UC(FC()),null,2)),u(!0),window.setTimeout(()=>u(!1),1500)}catch{u(!1)}},h=b=>{const v=t.history.find(w=>w.id===b);v&&n(v.request,v.scripts,v.collectionId,v.folderId)},g=b=>{const v=t.history.find(w=>w.id===b);v&&(typeof window<"u"&&!window.confirm(`Delete this history entry? -${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(O=>O.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,O]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",E=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",M=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,q=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),R=I.useMemo(()=>xM(q),[q]),J=C?R.find(T=>T.kind==="run"&&T.group.runId===C):void 0,U=J?.kind==="run"?J.group:void 0,B=U?void 0:q.find(T=>T.id===w)||q[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,W=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,ye=()=>{A(void 0),O(void 0)},me=T=>{A(T),O(void 0)},fe=T=>{O(T),A(void 0)},L=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},Q=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(he=>he.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),ye())},ue=B?.responseHeaders||[],ve=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${E}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),ye()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),ye()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[R.map(T=>{if(T.kind==="entry"){const ne=T.entry,ke=B?.id===ne.id,_e=eu(ne),$e=ne.collectionId?t.collections.find(Pe=>Pe.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${ke?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:_e?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:$e||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,he=U?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${he?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>fe(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>me(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),q.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[U&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:U.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[U.captured," / ",U.total," history entries captured · ",x1(U)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:U.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>me(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!U&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${W?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>L(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>Q(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),ue.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:ue.map(([T,z],he)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${he}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${M}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[ve,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scriptLogs.join(` -`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${M}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function at(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?at(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=at(r.key).trim();return a?[{id:An("variable"),key:a,value:at(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. -${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(at).join(` -`):at(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=at(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` +${v.executedMethod.toUpperCase()} ${v.resolvedUrl}`)||e(w=>({...w,history:w.history.filter(A=>A.id!==b)})))};return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-history-heading",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-history-heading",className:"font-semibold",children:"Recent history"})]}),t.history.length>0&&r&&p.jsx("button",{type:"button",className:`text-xs underline underline-offset-2 ${a}`,onClick:r,children:"View all"})]}),p.jsxs("label",{className:"flex items-center gap-2 rounded-md border p-2 text-xs",title:"Sensitive history headers are always redacted.",children:[p.jsx("input",{type:"checkbox",checked:t.historyBodies!==!1,onChange:b=>e(v=>({...v,historyBodies:b.target.checked}))}),p.jsx("span",{children:"Store API-host bodies"})]}),p.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border p-2 text-xs",children:[p.jsx("span",{className:a,title:"Counts and duration percentiles for this tab. No URLs, headers, bodies or credentials.",children:"Transport observation"}),p.jsxs("span",{className:"flex items-center gap-2",children:[p.jsx("button",{type:"button",className:"underline underline-offset-2",onClick:f,children:c?"Copied":"Copy"}),p.jsx("button",{type:"button",className:`underline underline-offset-2 ${a}`,onClick:()=>{PC(),u(!1)},children:"Reset"})]})]}),p.jsxs("div",{className:"space-y-1",children:[t.history.slice(0,5).map(b=>{const v=b.status!==void 0?`${b.status}${b.statusText?` ${b.statusText}`:""}`:b.error?"Error":"Sent",w=b.responseTime!==void 0?` · ${b.responseTime} ms`:"",A=b.scriptTests?.filter(E=>E.passed).length||0,C=b.scriptTests?.length?`${A}/${b.scriptTests.length} tests passed`:b.scriptError?"Script error":void 0;return p.jsxs("div",{className:"group flex items-start gap-1 rounded-md",children:[p.jsxs("button",{type:"button",className:"min-w-0 flex-1 rounded-md px-2 py-2 text-left hover:bg-blue-500/10","aria-label":`Load history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>h(b.id),children:[p.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[p.jsx("span",{className:"font-mono font-semibold text-blue-600",children:b.executedMethod.toUpperCase()}),p.jsxs("span",{className:b.error?"text-red-600":a,children:[v,w]})]}),p.jsx("div",{className:"truncate font-mono text-xs",title:b.resolvedUrl,children:b.resolvedUrl}),C&&p.jsx("div",{className:`mt-1 text-[11px] ${b.scriptError?"text-red-600":a}`,children:C}),p.jsx("div",{className:`mt-1 text-[11px] ${a}`,children:lp(b.createdAt)})]}),p.jsx("button",{type:"button",className:"rounded-md p-2 opacity-70 hover:opacity-100","aria-label":`Delete history request ${b.executedMethod.toUpperCase()} ${b.resolvedUrl}`,onClick:()=>g(b.id),children:p.jsx(fi,{className:"h-4 w-4"})})]},b.id)}),t.history.length===0&&p.jsx("div",{className:`rounded-md border border-dashed px-3 py-3 text-xs ${a}`,children:"Sent requests appear here for quick replay. Import or open a collection request, then Send it to start building history."})]}),t.history.length>0&&r&&p.jsxs("button",{type:"button",className:"w-full rounded-md border px-3 py-2 text-xs font-medium hover:bg-blue-500/10",onClick:r,children:["Open full history · ",t.history.length]})]})};function ap(t){return t.error?"Request failed":t.status!==void 0?`${t.status}${t.statusText?` ${t.statusText}`:""}`:"Sent"}function wM(t){return(t||[]).filter(e=>e.enabled!==!1&&(e.key.trim()||e.value.trim()))}const Al="text-xs font-semibold uppercase tracking-wide",g1="font-mono font-semibold text-blue-600",y1="mt-1 truncate font-mono text-xs";function b1({title:t,values:e,mutedClass:n}){const r=wM(e);return r.length===0?null:p.jsxs("section",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:t}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:r.map((s,a)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:s.key||"—"}),p.jsx("span",{className:`break-all font-mono ${n}`,children:s.value})]},`${s.key}:${a}`))})]})}function x1(t){const e=[`${t.passed} runner passed`,`${t.failed} runner failed`];return t.cancelled&&e.push(`${t.cancelled} cancelled`),e.join(" · ")}const SM=({workspace:t,onWorkspaceChange:e,onLoadRequest:n,onBack:r,theme:s,initialEntryId:a,initialRunId:c})=>{const[u,f]=I.useState(""),[h,g]=I.useState("all"),[b,v]=I.useState("all"),[w,A]=I.useState(c?void 0:a||t.history[0]?.id),[C,E]=I.useState(c),D=s==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",O=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",j=s==="dark"?"text-gray-400":"text-gray-500",R=s==="dark"?"border-gray-700 bg-gray-950 text-gray-100":"border-gray-200 bg-white text-gray-900",_=`rounded-md border px-3 py-2 text-sm ${D}`,L=I.useMemo(()=>bM(t,{query:u,method:h,outcome:b}),[h,b,u,t]),M=I.useMemo(()=>xM(L),[L]),G=C?M.find(T=>T.kind==="run"&&T.group.runId===C):void 0,Y=G?.kind==="run"?G.group:void 0,B=Y?void 0:L.find(T=>T.id===w)||L[0],K=B?.collectionId?t.collections.find(T=>T.id===B.collectionId):void 0,ee=B?.folderId?t.folders.find(T=>T.id===B.folderId):void 0,be=()=>{A(void 0),E(void 0)},ce=T=>{A(T),E(void 0)},ge=T=>{E(T),A(void 0)},q=T=>{n(T.request,T.scripts,T.collectionId,T.folderId),r()},J=T=>{window.confirm("Delete this history entry? This cannot be undone.")&&(e(z=>({...z,history:z.history.filter(me=>me.id!==T)})),w===T&&A(void 0))},oe=()=>{window.confirm("Clear all request history? This cannot be undone.")&&(e(T=>({...T,history:[]})),be())},he=B?.responseHeaders||[],Se=B?.scriptTests?.filter(T=>T.passed).length||0;return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${O}`,"aria-labelledby":"api-client-history-page-heading",children:p.jsxs("div",{className:"space-y-4",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("div",{className:"flex items-center gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:r,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(kd,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-history-page-heading",className:"text-lg font-semibold",children:"Request history"})]}),p.jsxs("p",{className:`text-xs ${j}`,children:[t.history.length," persisted request",t.history.length===1?"":"s"," · newest first"]})]})]}),t.history.length>0&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 self-start rounded-md border px-3 py-2 text-sm text-red-600",onClick:oe,children:[p.jsx(fi,{className:"h-4 w-4"})," Clear history"]})]}),p.jsxs("div",{className:"grid gap-2 md:grid-cols-[minmax(0,1fr)_10rem_12rem]",children:[p.jsxs("label",{className:"relative",children:[p.jsx("span",{className:"sr-only",children:"Search history"}),p.jsx(Hg,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 ${j}`}),p.jsx("input",{"aria-label":"Search history",className:`w-full rounded-md border py-2 pl-9 pr-3 text-sm ${D}`,value:u,onChange:T=>{f(T.target.value),be()},placeholder:"Search URL, status, collection or run…"})]}),p.jsxs("select",{"aria-label":"History method filter",className:_,value:h,onChange:T=>{g(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All methods"}),["GET","POST","PUT","PATCH","DELETE","HEAD","OPTIONS"].map(T=>p.jsx("option",{value:T,children:T},T))]}),p.jsxs("select",{"aria-label":"History outcome filter",className:_,value:b,onChange:T=>{v(T.target.value),be()},children:[p.jsx("option",{value:"all",children:"All outcomes"}),p.jsx("option",{value:"success",children:"Successful HTTP"}),p.jsx("option",{value:"failed",children:"HTTP / script failures"}),p.jsx("option",{value:"tests",children:"With tests"})]})]}),p.jsxs("div",{className:"grid min-h-[32rem] gap-4 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,1.35fr)]",children:[p.jsxs("div",{className:"max-h-[48rem] space-y-2 overflow-auto rounded-lg border p-2",children:[M.map(T=>{if(T.kind==="entry"){const ne=T.entry,Ce=B?.id===ne.id,Re=eu(ne),qe=ne.collectionId?t.collections.find(He=>He.id===ne.collectionId)?.name||"Deleted collection":void 0;return p.jsxs("button",{type:"button",className:`w-full rounded-md border px-3 py-3 text-left transition ${Ce?"border-blue-500 bg-blue-500/10":"border-transparent hover:bg-blue-500/5"}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-3 text-xs",children:[p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()}),p.jsxs("span",{className:Re?"text-red-600":j,children:[ap(ne),ne.responseTime!==void 0?` · ${ne.responseTime} ms`:""]})]}),p.jsx("div",{className:y1,title:ne.resolvedUrl,children:ne.resolvedUrl}),p.jsxs("div",{className:`mt-1 flex items-center justify-between gap-2 text-[11px] ${j}`,children:[p.jsx("span",{className:"truncate",children:qe||"Unsaved request"}),p.jsx("span",{children:lp(ne.createdAt)})]})]},ne.id)}const z=T.group,me=Y?.runId===z.runId;return p.jsxs("div",{className:`rounded-lg border ${me?"border-blue-500 bg-blue-500/5":""}`,children:[p.jsxs("button",{type:"button","aria-label":`Open collection run ${z.runName}`,className:"w-full px-3 py-3 text-left",onClick:()=>ge(z.runId),children:[p.jsx("div",{className:"text-xs font-semibold text-blue-600",children:"Collection run"}),p.jsx("div",{className:"mt-1 truncate text-sm font-medium",children:z.runName}),p.jsxs("div",{className:`mt-1 text-[11px] ${j}`,children:[z.captured,"/",z.total," history entries · ",x1(z)]})]}),p.jsx("div",{className:"border-t px-2 py-1",children:z.entries.map(ne=>p.jsxs("button",{type:"button",className:`w-full rounded-md px-2 py-2 text-left text-xs hover:bg-blue-500/10 ${B?.id===ne.id?"bg-blue-500/10":""}`,onClick:()=>ce(ne.id),children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsxs("span",{children:[p.jsx("span",{className:"mr-2 text-[10px] text-gray-500",children:ne.runIndex||"–"}),p.jsx("span",{className:g1,children:ne.executedMethod.toUpperCase()})]}),p.jsx("span",{className:eu(ne)?"text-red-600":j,children:ap(ne)})]}),p.jsx("div",{className:"mt-1 truncate font-mono",title:ne.resolvedUrl,children:ne.resolvedUrl})]},ne.id))})]},z.runId)}),L.length===0&&p.jsx("div",{className:`px-3 py-8 text-center text-sm ${j}`,children:t.history.length===0?"Send a request to start building history.":"No history entries match these filters."})]}),p.jsxs("div",{className:"min-w-0 rounded-lg border p-4",children:[Y&&p.jsxs("div",{className:"space-y-4",children:[p.jsxs("div",{className:"border-b pb-4",children:[p.jsx("div",{className:"text-xs font-semibold uppercase tracking-wide text-blue-600",children:"Collection run"}),p.jsx("h3",{className:"mt-1 text-lg font-semibold",children:Y.runName}),p.jsxs("p",{className:`mt-1 text-sm ${j}`,children:[Y.captured," / ",Y.total," history entries captured · ",x1(Y)]}),p.jsx("p",{className:`mt-2 text-xs ${j}`,children:"Runner pass/fail is based on transport, scripts, and tests. An HTTP 4xx/5xx can therefore be a runner pass while still appearing as an HTTP failure in the request inspector."})]}),p.jsx("div",{className:"space-y-2",children:Y.entries.map(T=>p.jsxs("button",{type:"button","aria-label":`Inspect history ${T.runIndex||""}`,className:"w-full rounded-md border px-3 py-3 text-left hover:bg-blue-500/5",onClick:()=>ce(T.id),children:[p.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 text-sm",children:[p.jsxs("span",{children:[p.jsx("span",{className:`mr-2 text-xs ${j}`,children:T.runIndex||"–"}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:T.executedMethod.toUpperCase()})]}),p.jsxs("span",{className:T.runPassed===!1?"text-red-600":T.runPassed===!0?"text-green-600":j,children:[T.runPassed===!0?"Runner pass":T.runPassed===!1?"Runner fail":"Recorded",T.status!==void 0?` · HTTP ${T.status}`:""]})]}),p.jsx("div",{className:y1,children:T.resolvedUrl})]},T.id))})]}),!Y&&!B&&p.jsx("div",{className:`flex min-h-[20rem] items-center justify-center text-sm ${j}`,children:"Select a history entry or collection run to inspect it."}),B&&p.jsxs("div",{className:"space-y-5",children:[p.jsxs("div",{className:"space-y-2 border-b pb-4",children:[p.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:"font-mono font-bold text-blue-600",children:B.executedMethod.toUpperCase()}),p.jsx("span",{className:eu(B)?"text-red-600":j,children:ap(B)}),B.responseTime!==void 0&&p.jsxs("span",{className:j,children:[B.responseTime," ms"]}),B.runPassed!==void 0&&p.jsx("span",{className:B.runPassed?"text-green-600":"text-red-600",children:B.runPassed?"Runner pass":"Runner fail"})]}),p.jsx("div",{className:"mt-1 break-all font-mono text-sm",children:B.resolvedUrl}),p.jsxs("div",{className:`mt-1 text-xs ${j}`,children:[lp(B.createdAt),B.collectionId?` · ${K?.name||"Deleted collection"}`:"",B.folderId?` / ${ee?.name||"Deleted folder"}`:"",B.runName?` · Run: ${B.runName}`:""]})]}),p.jsxs("div",{className:"flex shrink-0 gap-2",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium hover:bg-blue-500/10",onClick:()=>q(B),children:[p.jsx(ek,{className:"h-4 w-4"})," Open in client"]}),p.jsx("button",{type:"button","aria-label":"Delete selected history entry",className:"inline-flex min-h-10 items-center rounded-md border px-3 py-2 text-red-600",onClick:()=>J(B.id),children:p.jsx(fi,{className:"h-4 w-4"})})]})]}),B.error&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.error})]}),p.jsxs("section",{className:"space-y-3",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Request"}),B.requestBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),p.jsxs("div",{className:"grid gap-3 text-xs sm:grid-cols-2",children:[p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Original URL"}),p.jsx("div",{className:"mt-1 break-all font-mono",children:B.request.url})]}),p.jsxs("div",{children:[p.jsx("span",{className:j,children:"Content type"}),p.jsx("div",{className:"mt-1 font-mono",children:B.request.contentType||"—"})]})]}),p.jsx(b1,{title:"Query parameters",values:B.request.query,mutedClass:j}),p.jsx(b1,{title:"Headers",values:B.request.headers,mutedClass:j}),B.request.body&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.request.body})]})]}),p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("h3",{className:"font-semibold",children:"Response"}),B.responseBodyTruncated&&p.jsx("span",{className:"text-xs text-amber-600",children:"Body truncated in history"})]}),he.length>0&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Headers"}),p.jsx("div",{className:"overflow-hidden rounded-md border",children:he.map(([T,z],me)=>p.jsxs("div",{className:"grid grid-cols-[minmax(8rem,0.35fr)_minmax(0,1fr)] gap-3 border-b px-3 py-2 text-xs last:border-b-0",children:[p.jsx("span",{className:"break-all font-mono font-medium",children:T}),p.jsx("span",{className:`break-all font-mono ${j}`,children:z})]},`${T}:${me}`))})]}),B.responseBody!==void 0?p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Body"}),p.jsx("pre",{className:`max-h-96 overflow-auto whitespace-pre-wrap break-words rounded-md border p-3 text-xs ${R}`,children:B.responseBody||"(empty response body)"})]}):p.jsx("p",{className:`text-sm ${j}`,children:"Response payload was not captured for this older history entry."})]}),(B.scriptTests?.length||B.scriptError||B.scriptLogs?.length)&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Tests & console"}),B.scriptTests?.length?p.jsxs("div",{className:"space-y-1",children:[p.jsxs("div",{className:`text-xs ${j}`,children:[Se,"/",B.scriptTests.length," tests passed"]}),B.scriptTests.map((T,z)=>p.jsxs("div",{className:`rounded-md border px-3 py-2 text-sm ${T.passed?"":"border-red-300 bg-red-500/10 text-red-700"}`,children:[p.jsxs("span",{className:"font-medium",children:[T.passed?"✓":"✕"," ",T.name]}),T.error&&p.jsx("div",{className:"mt-1 text-xs",children:T.error})]},`${T.name}:${z}`))]}):null,B.scriptError&&p.jsx("div",{className:"rounded-md border border-red-300 bg-red-500/10 px-3 py-2 text-sm text-red-700",children:B.scriptError}),B.scriptLogs?.length?p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scriptLogs.join(` +`)}):null]}),(B.scripts?.preRequest.trim()||B.scripts?.tests.trim())&&p.jsxs("section",{className:"space-y-3 border-t pt-4",children:[p.jsx("h3",{className:"font-semibold",children:"Scripts used"}),B.scripts?.preRequest.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Pre-request"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.preRequest})]}),B.scripts?.tests.trim()&&p.jsxs("div",{className:"space-y-2",children:[p.jsx("h4",{className:Al,children:"Tests"}),p.jsx("pre",{className:`max-h-56 overflow-auto whitespace-pre-wrap rounded-md border p-3 text-xs ${R}`,children:B.scripts.tests})]})]})]})]})]})]})})};function mn(t){return!!t&&typeof t=="object"&&!Array.isArray(t)}function lt(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);try{return JSON.stringify(t)}catch{return String(t)}}function ei(t,e,n,r){t.push({code:e,path:n,message:r})}function Xr(t){return Array.isArray(t)?t.filter(mn):[]}function tt(t,e,n){const r=Xr(t[e]).find(s=>s.key===n);return r?lt(r.value):""}function AM(t){switch(t){case"authorization_code":return"authorizationCode";case"client_credentials":return"clientCredentials";case"password_credentials":case"password":return"password";case"implicit":return"implicit";case"access_token":return"accessToken";default:return}}function op(t,e,n,r){if(!mn(t)||typeof t.type!="string")return{...e};const s=t.type.toLowerCase();if(s==="inherit")return{...e};if(s==="noauth")return{type:"none"};if(s==="bearer")return{type:"bearer",token:tt(t,"bearer","token")};if(s==="basic")return{type:"basic",username:tt(t,"basic","username"),password:tt(t,"basic","password")};if(s==="apikey"){const c=tt(t,"apikey","in").toLowerCase();return c==="cookie"?ei(r,"postman-auth-host-execution",n,"Imported Postman cookie API key requires FlexDoc API host execution; the browser will not send this auth mode directly."):c&&c!=="header"&&c!=="query"&&ei(r,"postman-auth-apikey-location",n,`Unsupported Postman API-key location "${c}"; imported as a header API key.`),{type:"apiKey",key:tt(t,"apikey","key"),value:tt(t,"apikey","value"),in:c==="query"?"query":c==="cookie"?"cookie":"header"}}if(s==="oauth2"){const c=tt(t,"oauth2","scope"),u=AM(tt(t,"oauth2","grant_type")),f=tt(t,"oauth2","client_authentication").toLowerCase();return{type:"oauth2",accessToken:tt(t,"oauth2","accessToken"),...u?{grantType:u}:{},authorizationUrl:tt(t,"oauth2","authUrl")||void 0,tokenUrl:tt(t,"oauth2","accessTokenUrl")||void 0,clientId:tt(t,"oauth2","clientId")||void 0,clientSecret:tt(t,"oauth2","clientSecret")||void 0,clientAuthentication:f==="header"||f==="basic"?"basic":"body",redirectUri:tt(t,"oauth2","redirect_uri")||void 0,scopes:c?c.split(/[\s,]+/).filter(Boolean):void 0,username:tt(t,"oauth2","username")||void 0,password:tt(t,"oauth2","password")||void 0,refreshToken:tt(t,"oauth2","refreshToken")||void 0}}const a=c=>ei(r,"postman-auth-host-execution",n,`Imported Postman ${c} auth requires FlexDoc API host execution; the browser will not send this auth mode directly.`);if(s==="digest")return a("Digest"),{type:"digest",username:tt(t,"digest","username"),password:tt(t,"digest","password")};if(s==="hawk"){a("Hawk");const c=tt(t,"hawk","algorithm").toLowerCase();return{type:"hawk",id:tt(t,"hawk","authId")||tt(t,"hawk","id"),key:tt(t,"hawk","authKey")||tt(t,"hawk","key"),algorithm:c==="sha1"?"sha1":"sha256",ext:tt(t,"hawk","extraData")||tt(t,"hawk","ext")||void 0}}if(s==="ntlm")return a("NTLM/Negotiate"),{type:"ntlm",username:tt(t,"ntlm","username"),password:tt(t,"ntlm","password"),domain:tt(t,"ntlm","domain")||void 0,workstation:tt(t,"ntlm","workstation")||void 0};if(s==="oauth1"){a("OAuth 1.0");const c=tt(t,"oauth1","signatureMethod").toUpperCase();return{type:"oauth1",consumerKey:tt(t,"oauth1","consumerKey"),consumerSecret:tt(t,"oauth1","consumerSecret"),token:tt(t,"oauth1","token")||void 0,tokenSecret:tt(t,"oauth1","tokenSecret")||void 0,signatureMethod:c==="HMAC-SHA256"||c==="PLAINTEXT"?c:"HMAC-SHA1",realm:tt(t,"oauth1","realm")||void 0}}return s==="awsv4"?(a("AWS Signature V4"),{type:"awsv4",accessKey:tt(t,"awsv4","accessKey"),secretKey:tt(t,"awsv4","secretKey"),sessionToken:tt(t,"awsv4","sessionToken")||void 0,region:tt(t,"awsv4","region"),service:tt(t,"awsv4","service")}):(ei(r,"postman-auth-unsupported",n,`Postman auth type "${t.type}" is not supported by FlexDoc and was left to inherited/default auth.`),{...e})}function v1(t,e,n){return Xr(t).flatMap((r,s)=>{const a=lt(r.key).trim();return a?[{id:An("variable"),key:a,value:lt(r.value),enabled:r.disabled!==!0&&r.enabled!==!1}]:(ei(n,"postman-variable-empty-key",`${e}[${s}]`,"Skipped a Postman variable with an empty key."),[])})}function kM(t,e,n){const r=["pm.sendRequest","pm.globals","pm.iterationData","pm.cookies","pm.vault","pm.require","pm.execution","postman."].filter(a=>t.includes(a));let s=t.replace(/\bpm\.response\.to\.have\.status\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.code).to.equal($1);").replace(/\bpm\.response\.to\.have\.header\(([^)\n]+)\)\s*;?/g,"flex.expect(flex.response?.headers.has($1)).to.equal(true);").replace(/\bpm\.collectionVariables\b/g,"flex.collection").replace(/\bpm\.environment\b/g,"flex.environment").replace(/\bpm\.variables\b/g,"flex.variables").replace(/\bpm\.request\b/g,"flex.request").replace(/\bpm\.response\b/g,"flex.response").replace(/\bpm\.expect\b/g,"flex.expect").replace(/\bpm\.test\b/g,"flex.test").replace(/\bflex\.request\.headers\.add\s*\(/g,"flex.request.headers.upsert(");return/\bpm\./.test(s)&&r.push("other pm.* APIs"),r.length>0&&(ei(n,"postman-script-partial-compatibility",e,`Imported script uses unsupported Postman APIs (${[...new Set(r)].join(", ")}); review the script before relying on it.`),s=`// Imported from Postman. Review unsupported API usage before relying on this script. +${s}`),s}function CM(t,e,n){return mn(t)?(t.src!==void 0&&ei(n,"postman-script-src",e,"External Postman script sources are not fetched; only inline script.exec content is imported."),Array.isArray(t.exec)?t.exec.map(lt).join(` +`):lt(t.exec)):""}function w1(t,e,n){const r={preRequest:[],tests:[]};return Xr(t).forEach((s,a)=>{const c=lt(s.listen).toLowerCase();if(c!=="prerequest"&&c!=="test")return;const u=`${e}[${a}]`,f=CM(s.script,`${u}.script`,n).trim();if(!f)return;const h=kM(f,`${u}.script`,n);c==="prerequest"?r.preRequest.push(h):r.tests.push(h)}),r}function NM(t,e){return{preRequest:[...t.preRequest,...e.preRequest],tests:[...t.tests,...e.tests]}}function TM(t){const e=t.preRequest.filter(Boolean).join(` `).trim(),n=t.tests.filter(Boolean).join(` -`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=at(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=at(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=at(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(at).join("."):at(t.host),a=at(t.port),c=Array.isArray(t.path)?t.path.map(at).join("/"):at(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:at(e.key),value:at(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=at(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?at(c.language):"";return{body:at(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:at(u.key),value:at(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=at(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:at(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=at(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(at).filter(Boolean).join(", "):at(f.src);return{key:at(f.key),value:h==="text"?at(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?at(t.file.src):at(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=at(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=at(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=at(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=at(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=at(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],O=[],D=[];for(const q of A)try{const R=JSON.parse(await q.text()),J=$M(R);C.push(J),O.push(...J.result.warnings.map(U=>({...U,path:`${q.name}:${U.path}`})))}catch(R){D.push(`${q.name}: ${R instanceof Error?R.message:String(R)}`)}C.length>0&&t(q=>{let R=q;for(const J of C)R=J.kind==="collection"?HM(R,J.result):zM(R,J.result);return R});const E=C.filter(q=>q.kind==="collection"),j=C.length-E.length,M=E[E.length-1];M?.kind==="collection"&&e?.(M.result.collection.id),u(O);const _=[E.length>0?N1(E.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||O.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${O.length} compatibility warning${O.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),O=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(Q=>Q.id===t.activeEnvironmentId),[E,j]=I.useState(!1),[M,_]=I.useState(!1),[q,R]=I.useState(),[J,U]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const W=async()=>{if(M||C.length===0)return;const Q=new AbortController;B.current=Q,_(!0),R(void 0),U(Object.fromEntries(C.map(ue=>[ue.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:O,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:E,signal:Q.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:ue=>{K.current&&U(ve=>({...ve,[ue.id]:{status:"running"}}))},onRequestComplete:ue=>{K.current&&U(ve=>({...ve,[ue.requestId]:{status:ue.cancelled?"cancelled":ue.passed?"passed":"failed",item:ue}}))}});K.current&&(e(oe.workspace),U(ue=>Object.fromEntries(C.map(ve=>{const T=ue[ve.id]||{status:"pending"};return[ve.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),R(oe),_(!1),B.current=void 0)},ye=()=>B.current?.abort(),me=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",fe=s==="dark"?"text-gray-400":"text-gray-500",L=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${me}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:O}),p.jsxs("p",{className:`mt-1 text-xs ${fe}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[q?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,q.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),M?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:ye,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{W()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",q?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:E,disabled:M,onChange:Q=>j(Q.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${fe}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),q&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Progress"}),p.jsxs("strong",{children:[q.completed," / ",q.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:q.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:q.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Cancelled"}),p.jsx("strong",{children:q.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:fe,children:"Run"}),p.jsx("strong",{children:q.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${fe}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((Q,oe)=>{const ue=J[Q.id]||{status:"pending"},ve=ue.item?.outcome.result,T=ue.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,he=ve?.status!==void 0&&ve.status>=400;return p.jsxs("div",{"data-runner-request-id":Q.id,className:`rounded-lg border p-3 ${L}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${fe}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:Q.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:Q.name})]}),p.jsx("div",{className:`mt-1 text-xs ${fe}`,children:VM(t,Q)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:Q.request.url,children:Q.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[ue.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),ue.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),ue.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(ue)}),ve?.status!==void 0&&p.jsxs("span",{className:he?"text-amber-600":fe,children:["HTTP ",ve.status]}),ve?.responseTime!==void 0&&p.jsxs("span",{className:fe,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),ve.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":fe}`,children:[z,"/",T.length," tests passed"]}),ue.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.scriptError}),ue.item?.outcome.error&&!ue.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:ue.item.outcome.error}),ue.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${Q.name}`,onClick:()=>v(ue.item?.historyEntryId,ue.item?.outcome.result?q?.runId:void 0),children:"Inspect history"})]},Q.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${fe}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:O,onExecutionStart:D,onExecutionComplete:E,variables:j={},environmentVariables:M={},onCollectionChanges:_,onEnvironmentChanges:q,...R})=>{const J=YM(t),U=Sn(e),B=nl(),K=a===!1?{}:j1(a),[W,ye]=I.useState(J),[me,fe]=I.useState(J),[L,Q]=I.useState(U),[oe,ue]=I.useState(U),[ve,T]=I.useState(R.initialServerUrl),[z,he]=I.useState(0),[ne,ke]=I.useState(n||K.requestTab||"params"),[_e,$e]=I.useState(r||K.scriptTab||cp(U)),[Pe,Ke]=I.useState("request"),[Ie,ut]=I.useState({}),[Rt,Ce]=I.useState(),[Ee,G]=I.useState(B),[Se,Ne]=I.useState(B.collections[0]?.id),[Re,Ge]=I.useState(""),st=I.useRef(B.collections[0]?.id),Et=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ht,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),St=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let De=!1;return hy(a).then(Ze=>{De||(G(Ze),Ne(Ze.collections[0]?.id),Ge(""),Tn(!0))}).catch(()=>{De||Tn(!0)}),()=>{De=!0}},[a]);const x=my(a,Ee,ti),V=I.useMemo(()=>uy(Ee,Se),[Se,Ee]),pe=I.useMemo(()=>ff(Ee),[Ee]),ae=I.useMemo(()=>({...M,...pe}),[M,pe]),X=I.useMemo(()=>({...V,...j,...ae}),[V,ae,j]);I.useEffect(()=>{if(h===void 0)return;const De=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||G($t=>$t.activeEnvironmentId===De?$t:{...$t,activeEnvironmentId:De})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(me,oe),[me,oe]),F=I.useMemo(()=>KM(me,oe)&&!Ee.requests.some(De=>O1(De.request,De.scripts)===k),[k,me,oe,Ee.requests]);I.useEffect(()=>{b?.({environments:Ee.environments.map(({id:De,name:Ze})=>({id:De,name:Ze})),activeEnvironmentId:Ee.activeEnvironmentId,hasUnsavedRequest:F})},[F,b,Ee.activeEnvironmentId,Ee.environments]);const Z=I.useCallback(De=>cy(Ee,Se,Re||void 0,De||{type:"none"}),[Se,Re,Ee]),xe=I.useCallback(De=>{Ne(De),Ge("")},[]),P=De=>{v?.(De)},ce=De=>{fe(Ei(De)),w?.(Ei(De))},le=De=>{const Ze=Sn(De);ue(Ze),A?.(Ze)},we=De=>{ke(De),a!==!1&&Ua(a,{requestTab:De}),C?.(De)},Oe=De=>{$e(De),a!==!1&&Ua(a,{scriptTab:De}),O?.(De)},Te=De=>{const Ze=st.current||Se;G($t=>dy($t,Ze,De)),_?.(De)},Be=De=>{G(Ze=>hf(Ze,De)),q?.(De)},ze=()=>{st.current=Se,Et.current=Re||void 0,D?.()},Ve=De=>{G(Ze=>oy(Ze,{...De,collectionId:st.current,folderId:Et.current})),E?.(De)},Dt=(De,Ze,$t,Bn)=>{Ke("request");const ii=$t&&Ee.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&Ne(ii);const En=ii||Se,_t=Bn&&Ee.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";Ge(_t);const Yt=Ei(De),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);ke(Jr),$e(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),ye(Yt),fe(Yt),Q(Pn),ue(Pn),T(void 0),he(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const De=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(De,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Ke("request"),ye(De),fe(De),Q(Ze),ue(Ze),T(f.serverUrl),ke($t),$e(Bn),he(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(De,Ze)=>{Ne(De),Ge(Ze||""),Ce({collectionId:De,folderId:Ze}),Ke("runner")},jn=(De,Ze)=>{ut({entryId:De,runId:Ze}),Ke("history")},Va=()=>ni(De=>{const Ze=!De;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=St==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=St==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ht?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ht?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ht?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ht?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ht,onClick:Va,children:ht?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ht&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:St,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:G,onSelectedCollectionChange:xe,theme:St}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ee,onWorkspaceChange:G,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:me,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:xe,onSelectedFolderChange:Ge,onRunCollection:De=>Fn(De),onRunFolder:(De,Ze)=>Fn(De,Ze),selectedCollectionId:Se,selectedFolderId:Re,workspace:Ee,onWorkspaceChange:G,hostExecution:R.hostExecution,theme:St})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onViewAll:()=>jn(),theme:St})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:R.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":R.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ee.activeEnvironmentId||"",onChange:De=>{const Ze=De.target.value||void 0;G($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:R.messages?.noEnvironment||"No environment"}),Ee.environments.map(De=>p.jsx("option",{value:De.id,children:De.name},De.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${R.messages?.viewerTheme||"Theme"}: ${St==="dark"?R.messages?.lightTheme||"Light":R.messages?.darkTheme||"Dark"}`,"aria-pressed":St==="dark",onClick:()=>{const De=St==="dark"?"light":"dark";qn(De),a!==!1&&Ua(a,{theme:De})},children:[R.messages?.viewerTheme||"Theme",": ",St==="dark"?R.messages?.darkTheme||"Dark":R.messages?.lightTheme||"Light"]}),Pe==="request"&&F&&p.jsx("span",{"aria-label":"Unsaved request changes",children:R.messages?.unsavedChanges||"Unsaved changes"})]})]}),Pe==="history"?p.jsx(SM,{workspace:Ee,onWorkspaceChange:G,onLoadRequest:Dt,onBack:()=>Ke("request"),initialEntryId:Ie.entryId,initialRunId:Ie.runId,theme:St},`${Ie.runId||""}:${Ie.entryId||""}`):Pe==="runner"&&Rt?p.jsx(PM,{workspace:Ee,onWorkspaceChange:G,collectionId:Rt.collectionId,folderId:Rt.folderId,theme:St,credentials:R.credentials,requestInterceptor:R.requestInterceptor,hostExecution:R.hostExecution,externalVariables:j,externalEnvironmentVariables:M,onCollectionChanges:_,onEnvironmentChanges:q,onOpenHistory:jn,onBack:()=>Ke("request")}):p.jsx(e1,{...R,initialRequest:W,initialScripts:L,initialRequestTab:ne,initialScriptTab:_e,initialServerUrl:ve,theme:St,resolveAuth:Z,variables:X,collectionVariables:V,externalVariables:j,environmentVariables:ae,onCollectionChanges:Te,onEnvironmentChanges:Be,onDraftChange:ce,onScriptsChange:le,onRequestTabChange:we,onScriptTabChange:Oe,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ee.credentialStorage||"remember",onCredentialStorageChange:De=>G(Ze=>({...Ze,credentialStorage:De})),onRequestChange:P},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,O]=I.useState(),D=I.useRef(0),[E,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[M,_]=I.useState(void 0),[q,R]=I.useState(!1),[J,U]=I.useState(!1),[B,K]=I.useState(!1),[W,ye]=I.useState(),[me,fe]=I.useState(),[L,Q]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),ue=I.useRef(null),ve=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,he=T&&z&&me?.endpoint===z?me:void 0,ne=he?.snapshot,ke=he?.error,_e=!!(T&&z&&!he),$e=I.useCallback(()=>K(!1),[]),Pe=L.key===a?L.preferences:fa(a),Ke=n&&Pe.theme||e,Ie=Ke==="high-contrast"?"dark":Ke,ut=Pe.expand,Rt=Pe.expandedTags??["default"],Ce=Pe.sidebarCollapsed??!1,Ee=typeof s.theme=="object"?s.theme:void 0,G=I.useMemo(()=>({...GM(Ie,Ee),...r}),[Ie,Ee,r]);I.useEffect(()=>{if(!T||!z)return;const P=new AbortController;return fetch(z,{credentials:"same-origin",signal:P.signal}).then(async ce=>{if(!ce.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${ce.status}`);return V3(await ce.json())}).then(ce=>fe({endpoint:z,snapshot:ce})).catch(ce=>{P.signal.aborted||fe({endpoint:z,error:ce instanceof Error?ce.message:String(ce)})}),()=>P.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const P=document.createElement("style");return P.dataset.flexdocCustomCss="true",P.textContent=s.customCss,document.head.appendChild(P),()=>P.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const P=()=>g(R1(t,window.location.hash)),ce=()=>{const le=D1();v(le),le==="api-client"&&A(!0)};return P(),ce(),window.addEventListener("hashchange",P),window.addEventListener("popstate",ce),()=>{window.removeEventListener("hashchange",P),window.removeEventListener("popstate",ce)}},[t]),I.useEffect(()=>{if(!q||typeof document>"u")return;const P=document.body.style.overflow,ce=ue.current;document.body.style.overflow="hidden";const le=oe.current,we=()=>Array.from(le?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>we()[0]?.focus());const Oe=Te=>{if(Te.key==="Escape"){Te.preventDefault(),R(!1);return}if(Te.key!=="Tab")return;const Be=we();if(!Be.length)return;const ze=Be[0],Ve=Be[Be.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Oe),()=>{document.body.style.overflow=P,document.removeEventListener("keydown",Oe),ce?.focus()}},[q]);const Se=()=>{Q({key:a,preferences:fa(a)})},Ne=P=>{Q(ce=>{const le=ce.key===a?ce.preferences:fa(a);return{key:a,preferences:{...le,...P,version:1}}})},Re=()=>requestAnimationFrame(()=>ve.current?.scrollTo({top:0,behavior:"auto"})),Ge=(P,ce)=>{g({path:P,method:ce}),v("docs"),R(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(P,ce)),Re()},st=()=>{if(g(null),v("docs"),R(!1),typeof window<"u"){const P=new URL(window.location.href);P.searchParams.delete("view"),P.hash="",window.history.replaceState(null,"",`${P.pathname}${P.search}`)}Re()},Et=P=>{P&&(D.current+=1,O({id:D.current,request:P.request,scripts:P.scripts,requestTab:P.requestTab,scriptTab:P.scriptTab,serverUrl:P.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Re()},Tn=()=>{const P=!Ce;qo(a,"sidebarCollapsed",P),Ne({sidebarCollapsed:P})},ht=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=ut===void 0?ht:tf(ut),Vn=P=>{qo(a,"expand",P),Se()},qn=P=>{n&&(qo(a,"theme",P),Se())},St=P=>{qo(a,"expandedTags",P),Ne({expandedTags:P})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),V=L3(Ie,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Ie==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ae=Ie==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(P=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":P?"settings":void 0,className:P?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":J,onClick:()=>U(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),F=(P=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":P?"runtime":void 0,className:P?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ae}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!P&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:_e?"Runtime…":"Runtime"})]}):null,Z=(P=!1)=>p.jsx("button",{ref:ue,type:"button","data-flexdoc-floating-control":P?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":P?"floating":"topbar",className:P?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ae}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":q,onClick:()=>R(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),xe=p.jsx(pk,{spec:t,onEndpointSelect:Ge,theme:Ie,selectedEndpoint:h||void 0,expandedTags:Rt,onExpandedTagsChange:St,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:G,"data-theme":Ke,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[Z(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:st}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:st,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),F(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>ye(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&Z(!0),s.hideTopbar&&b==="docs"&&F(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ae}`,"aria-label":Ce?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!Ce,onClick:Tn,children:Ce?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ae}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ae}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Ie==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:M??E.activeEnvironmentId??"",onChange:P=>_(P.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),E.environments.map(P=>p.jsx("option",{value:P.id,children:P.name},P.id))]})]}),E.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${Ce?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":Ce?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!Ce&&xe}),p.jsxs("main",{ref:ve,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Ie,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:Et}):p.jsx(R3,{spec:t,onEndpointSelect:Ge,theme:Ie}),p.jsx(_3,{footerClasses:V,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Ie,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:M,onActiveEnvironmentIdChange:P=>_(P??null),onChromeStateChange:P=>{j(P),_(ce=>ce===void 0?P.activeEnvironmentId??null:ce)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),q&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>R(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Ie==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>R(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:xe})]})]}),W&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Ie==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>ye(void 0),children:X?.downloadFailed||W}),p.jsx(Z3,{open:B&&T,theme:Ie,loading:_e,error:ke,snapshot:ne,onClose:$e,onEndpointSelect:Ge,messages:X}),p.jsx(K3,{spec:t,theme:Ie,messages:X,onEndpointSelect:Ge,onHome:st,onOpenSettings:()=>U(!0),onOpenApiClient:()=>Et(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:J,theme:Ie,hostTheme:e,manageTheme:n,viewerTheme:Pe.theme,viewerExpand:ut,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>U(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); +`).trim();return e||n?{preRequest:e,tests:n}:void 0}function S1(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch{return t}}function A1(t){const e=t.split("#",1)[0],n=e.indexOf("?");if(n<0)return{url:e,query:[]};const r=e.slice(n+1),s=r?r.split("&").map(a=>{const c=a.indexOf("=");return{key:S1(c>=0?a.slice(0,c):a),value:S1(c>=0?a.slice(c+1):""),enabled:!0}}):[];return{url:e.slice(0,n),query:s}}function jM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function EM(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k1(t,e){let n=t;for(const r of Xr(e)){const s=lt(r.key).trim();s&&(n=n.replace(new RegExp(`:${EM(s)}(?=/|$)`,"g"),`{{${s}}}`))}return n}function OM(t){if(typeof t=="string")return A1(t);if(!mn(t))return{url:"",query:[]};const e=jM(t.query),n=lt(t.raw);if(n){const h=A1(n);return{url:k1(h.url,t.variable),query:e.length>0?e:h.query}}const r=lt(t.protocol).replace(/:$/,""),s=Array.isArray(t.host)?t.host.map(lt).join("."):lt(t.host),a=lt(t.port),c=Array.isArray(t.path)?t.path.map(lt).join("/"):lt(t.path).replace(/^\//,""),u=s?`${r?`${r}://`:""}${s}${a?`:${a}`:""}`:"",f=u?`${u}${c?`/${c}`:""}`:c;return{url:k1(f,t.variable),query:e}}function MM(t){return Xr(t).map(e=>({key:lt(e.key),value:lt(e.value),enabled:e.disabled!==!0}))}function RM(t){return t.find(e=>e.enabled!==!1&&e.key.toLowerCase()==="content-type")?.value}function DM(t){switch(t.toLowerCase()){case"json":return"application/json";case"xml":return"application/xml";case"html":return"text/html";case"javascript":return"application/javascript";case"text":return"text/plain";default:return}}function _M(t,e,n,r){const s=RM(e);if(!mn(t)||!t.mode)return{body:"",contentType:s||"application/json",bodyMode:"none"};const a=lt(t.mode);if(a==="raw"){const c=mn(t.options)&&mn(t.options.raw)?t.options.raw:void 0,u=c?lt(c.language):"";return{body:lt(t.raw),contentType:s||DM(u)||"text/plain",bodyMode:u.toLowerCase()==="json"?"json":"raw"}}if(a==="urlencoded")return{body:"",bodyMode:"urlencoded",urlencoded:Xr(t.urlencoded).map(u=>({key:lt(u.key),value:lt(u.value),enabled:u.disabled!==!0})),contentType:s||"application/x-www-form-urlencoded"};if(a==="graphql"){const c=mn(t.graphql)?t.graphql:{},u=lt(c.variables);return{body:"",bodyMode:"graphql",graphql:{query:lt(c.query),variables:u},contentType:s||"application/json"}}if(a==="formdata"){const c=Xr(t.formdata).map(f=>{const h=lt(f.type)==="file"?"file":"text",g=Array.isArray(f.src)?f.src.map(lt).filter(Boolean).join(", "):lt(f.src);return{key:lt(f.key),value:h==="text"?lt(f.value):"",enabled:f.disabled!==!0,type:h,...h==="file"&&g?{fileName:g}:{},...typeof f.contentType=="string"?{contentType:f.contentType}:{}}});return c.filter(f=>f.type==="file").length>0&&ei(r,"postman-body-formdata-files",n,"Multipart file fields were preserved, but exported local file paths cannot be reopened by the browser. Re-select those files before sending."),{body:"",bodyMode:"formdata",formData:c,contentType:s}}if(a==="file"){const c=mn(t.file)?lt(t.file.src):lt(t.src);return ei(r,"postman-body-file",n,c?`Postman binary file body "${c}" was preserved as intent, but browser security requires re-selecting the file before sending.`:"Postman binary file body requires selecting the file again in FlexDoc before sending."),{body:"",contentType:s||"application/octet-stream",bodyMode:"binary",binary:{fileName:c||void 0,contentType:s||"application/octet-stream"}}}return ei(r,"postman-body-unsupported",n,`Postman body mode "${a}" is not supported; the request body was left empty.`),{body:"",contentType:s||"application/octet-stream",bodyMode:"none"}}function LM(t,e,n,r,s,a,c,u){const f=typeof t=="string"?{method:"GET",url:t}:t;if(!mn(f))return ei(u,"postman-request-invalid",c,"Skipped an invalid Postman request entry."),null;const h=lt(f.method).trim().toUpperCase()||"GET",g=OM(f.url),b=MM(f.header),v=_M(f.body,b,`${c}.body`,u),w={method:h,url:g.url,query:g.query,headers:b,body:v.body,contentType:v.contentType,bodyMode:v.bodyMode,urlencoded:v.urlencoded,formData:v.formData,binary:v.binary,graphql:v.graphql,auth:op(f.auth,{type:"inherit"},`${c}.auth`,u)},A=TM(s);return{id:An("request"),collectionId:n,folderId:r,name:e.trim()||`${h} ${g.url||"request"}`,request:w,...A?{scripts:A}:{},createdAt:a,updatedAt:a}}function C1(t){Array.isArray(t.items)&&t.items.forEach((e,n)=>{const r=`${t.path}[${n}]`;if(!mn(e)){ei(t.warnings,"postman-item-invalid",r,"Skipped an invalid Postman item.");return}const s=lt(e.name)||"Untitled",a=w1(e.event,`${r}.event`,t.warnings),c=NM(t.inheritedScripts,a);if(Array.isArray(e.item)){const f=An("folder");t.folders.push({id:f,collectionId:t.collectionId,parentFolderId:t.parentFolderId,name:s,auth:op(e.auth,{type:"inherit"},`${r}.auth`,t.warnings),createdAt:t.timestamp,updatedAt:t.timestamp}),C1({...t,items:e.item,parentFolderId:f,inheritedScripts:c,path:`${r}.item`});return}const u=LM(e.request,s,t.collectionId,t.parentFolderId,c,t.timestamp,`${r}.request`,t.warnings);u&&t.requests.push(u)})}function qM(t){if(!mn(t)||!mn(t.info)||!Array.isArray(t.item))throw new Error("This JSON is not a Postman collection. Expected info and item fields.");const e=lt(t.info.name).trim();if(!e)throw new Error("Postman collection info.name is required.");const n=[],r=lt(t.info.schema);r&&!r.includes("/v2.1.0/")&&ei(n,"postman-schema-version","info.schema",`Collection schema "${r}" is not Postman v2.1; FlexDoc imported the compatible fields it recognized.`);const s=new Date().toISOString(),a=An("collection"),c={id:a,name:e,auth:op(t.auth,{type:"none"},"auth",n),variables:v1(t.variable,"variable",n),createdAt:s,updatedAt:s},u=[],f=[];return C1({items:t.item,collectionId:a,inheritedScripts:w1(t.event,"event",n),timestamp:s,path:"item",folders:u,requests:f,warnings:n}),{collection:c,folders:u,requests:f,warnings:n}}function BM(t){if(!mn(t)||!Array.isArray(t.values)||typeof t.name!="string")throw new Error("This JSON is not a Postman environment. Expected name and values fields.");const e=lt(t._postman_variable_scope).toLowerCase();if(e&&e!=="environment")throw new Error(`Postman variable scope "${e}" is not an environment.`);const n=[],r=new Date().toISOString();return{environment:{id:An("environment"),name:t.name.trim()||"Imported environment",variables:v1(t.values,"values",n),createdAt:r,updatedAt:r},warnings:n}}function $M(t){if(mn(t)&&mn(t.info)&&Array.isArray(t.item))return{kind:"collection",result:qM(t)};if(mn(t)&&Array.isArray(t.values)&&typeof t.name=="string")return{kind:"environment",result:BM(t)};throw new Error("Unsupported Postman JSON. Import a collection v2.1 JSON file or an exported environment JSON file.")}function IM(t){if(t.collections.length!==1||t.folders.length!==0||t.requests.length!==0)return!1;const e=t.collections[0];return e.name==="My Collection"&&e.auth.type==="none"&&e.variables.length===0}function HM(t,e){const n=IM(t)?[]:t.collections;return{...t,collections:[...n,e.collection],folders:[...t.folders,...e.folders],requests:[...t.requests,...e.requests]}}function zM(t,e){return{...t,environments:[...t.environments,e.environment],activeEnvironmentId:t.activeEnvironmentId||e.environment.id}}function N1(t,e){return`${t} ${t===1?e:`${e}s`}`}const UM=({onWorkspaceChange:t,onSelectedCollectionChange:e,theme:n})=>{const r=I.useRef(null),[s,a]=I.useState(null),[c,u]=I.useState([]),f=async A=>{if(A.length===0)return;const C=[],E=[],D=[];for(const L of A)try{const M=JSON.parse(await L.text()),G=$M(M);C.push(G),E.push(...G.result.warnings.map(Y=>({...Y,path:`${L.name}:${Y.path}`})))}catch(M){D.push(`${L.name}: ${M instanceof Error?M.message:String(M)}`)}C.length>0&&t(L=>{let M=L;for(const G of C)M=G.kind==="collection"?HM(M,G.result):zM(M,G.result);return M});const O=C.filter(L=>L.kind==="collection"),j=C.length-O.length,R=O[O.length-1];R?.kind==="collection"&&e?.(R.result.collection.id),u(E);const _=[O.length>0?N1(O.length,"collection"):"",j>0?N1(j,"environment"):""].filter(Boolean);C.length===0?a({tone:"error",text:D.join(" ")||"No Postman documents were imported."}):D.length>0||E.length>0?a({tone:"warning",text:`Imported ${_.join(" and ")}. ${D.length>0?`${D.length} file${D.length===1?"":"s"} failed to import.`:`${E.length} compatibility warning${E.length===1?"":"s"} need review.`}`}):a({tone:"success",text:`Imported ${_.join(" and ")}.`})},h=n==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900",g=n==="dark"?"text-gray-400":"text-gray-500",b=n==="dark"?"text-amber-300":"text-amber-700",v=n==="dark"?"text-emerald-300":"text-emerald-700",w=n==="dark"?"text-red-300":"text-red-700";return p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-import-heading",children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(Fg,{className:"h-4 w-4"}),p.jsx("h3",{id:"api-client-import-heading",className:"font-semibold",children:"Import"})]}),p.jsx("input",{ref:r,type:"file",accept:".json,application/json",multiple:!0,className:"hidden","aria-label":"Import Postman JSON",onChange:A=>{const C=Array.from(A.currentTarget.files||[]);A.currentTarget.value="",f(C)}}),p.jsxs("button",{type:"button",className:`flex w-full items-center justify-center gap-2 rounded-md border px-3 py-2 text-sm font-medium ${h}`,onClick:()=>r.current?.click(),children:[p.jsx(Fg,{className:"h-4 w-4"}),"Import Postman"]}),p.jsx("p",{className:`text-xs ${g}`,children:"Import Postman Collection v2.1 and exported environment JSON files. Multiple files can be selected together."}),s&&p.jsxs("div",{className:`flex items-start gap-2 text-xs ${s.tone==="success"?v:s.tone==="warning"?b:w}`,role:"status",children:[s.tone==="success"?p.jsx(oa,{className:"mt-0.5 h-4 w-4 shrink-0"}):p.jsx(Ed,{className:"mt-0.5 h-4 w-4 shrink-0"}),p.jsx("span",{children:s.text})]}),c.length>0&&p.jsxs("details",{className:`text-xs ${b}`,children:[p.jsxs("summary",{className:"cursor-pointer font-medium",children:["Review import warnings (",c.length,")"]}),p.jsxs("ul",{className:"mt-2 space-y-2 pl-4",children:[c.slice(0,5).map((A,C)=>p.jsxs("li",{children:[p.jsx("span",{className:"font-mono",children:A.path}),": ",A.message]},`${A.code}-${A.path}-${C}`)),c.length>5&&p.jsxs("li",{children:[c.length-5," more warning",c.length-5===1?"":"s"," not shown."]})]})]})]})};function VM(t,e){if(!e.folderId)return"Collection root";const n=new Map(t.folders.map(c=>[c.id,c])),r=[],s=new Set;let a=n.get(e.folderId);for(;a&&!s.has(a.id);)s.add(a.id),r.unshift(a.name),a=a.parentFolderId?n.get(a.parentFolderId):void 0;return r.join(" / ")||"Deleted folder"}function FM(t){return t.status==="running"?"Running":t.status==="passed"?"Runner pass":t.status==="failed"?"Runner fail":t.status==="cancelled"?"Cancelled":t.status==="skipped"?"Not run":"Pending"}const PM=({workspace:t,onWorkspaceChange:e,collectionId:n,folderId:r,theme:s,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,onCollectionChanges:g,onEnvironmentChanges:b,onOpenHistory:v,onBack:w,fetcher:A})=>{const C=I.useMemo(()=>Sl(t,n,r),[n,r,t]),E=I.useMemo(()=>m1(t,n,r),[n,r,t]),D=t.environments.find(J=>J.id===t.activeEnvironmentId),[O,j]=I.useState(!1),[R,_]=I.useState(!1),[L,M]=I.useState(),[G,Y]=I.useState({}),B=I.useRef(void 0),K=I.useRef(!0);I.useEffect(()=>(K.current=!0,()=>{K.current=!1,B.current?.abort()}),[]);const ee=async()=>{if(R||C.length===0)return;const J=new AbortController;B.current=J,_(!0),M(void 0),Y(Object.fromEntries(C.map(he=>[he.id,{status:"pending"}])));const oe=await pM({workspace:t,collectionId:n,folderId:r,runName:E,credentials:a,requestInterceptor:c,hostExecution:u,externalVariables:f,externalEnvironmentVariables:h,stopOnFailure:O,signal:J.signal,fetcher:A,onCollectionChanges:g,onEnvironmentChanges:b,onRequestStart:he=>{K.current&&Y(Se=>({...Se,[he.id]:{status:"running"}}))},onRequestComplete:he=>{K.current&&Y(Se=>({...Se,[he.requestId]:{status:he.cancelled?"cancelled":he.passed?"passed":"failed",item:he}}))}});K.current&&(e(oe.workspace),Y(he=>Object.fromEntries(C.map(Se=>{const T=he[Se.id]||{status:"pending"};return[Se.id,T.status==="pending"&&oe.stopped?{status:"skipped"}:T]}))),M(oe),_(!1),B.current=void 0)},be=()=>B.current?.abort(),ce=s==="dark"?"border-gray-700 bg-gray-800/60 text-gray-100":"border-gray-200 bg-gray-50 text-gray-900",ge=s==="dark"?"text-gray-400":"text-gray-500",q=s==="dark"?"border-gray-700 bg-gray-900/40":"border-gray-200 bg-white";return p.jsx("section",{className:`rounded-xl border p-4 md:p-5 ${ce}`,"aria-labelledby":"api-client-runner-heading",children:p.jsxs("div",{className:"space-y-5",children:[p.jsxs("header",{className:"flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"flex items-start gap-3",children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:w,children:[p.jsx(_o,{className:"h-4 w-4"})," Client"]}),p.jsxs("div",{children:[p.jsxs("div",{className:"flex items-center gap-2",children:[p.jsx(ca,{className:"h-5 w-5"}),p.jsx("h2",{id:"api-client-runner-heading",className:"text-lg font-semibold",children:"Collection runner"})]}),p.jsx("p",{className:"mt-1 text-sm font-medium",children:E}),p.jsxs("p",{className:`mt-1 text-xs ${ge}`,children:[C.length," saved request",C.length===1?"":"s"," · Environment: ",D?.name||"None"]})]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[L?.runId&&p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm",onClick:()=>v(void 0,L.runId),children:[p.jsx(KA,{className:"h-4 w-4"})," Open run history"]}),R?p.jsxs("button",{type:"button",className:"inline-flex min-h-10 items-center gap-2 rounded-md border border-red-300 px-3 py-2 text-sm text-red-700",onClick:be,children:[p.jsx(Ug,{className:"h-4 w-4"})," Stop run"]}):p.jsxs("button",{type:"button",disabled:C.length===0,className:"inline-flex min-h-10 items-center gap-2 rounded-md border px-3 py-2 text-sm font-medium disabled:cursor-not-allowed disabled:opacity-50",onClick:()=>{ee()},children:[p.jsx(ca,{className:"h-4 w-4"})," ",L?"Run again":"Start run"]})]})]}),p.jsxs("div",{className:"flex flex-col gap-3 rounded-lg border p-3 sm:flex-row sm:items-center sm:justify-between",children:[p.jsxs("label",{className:"inline-flex items-center gap-2 text-sm",children:[p.jsx("input",{type:"checkbox",checked:O,disabled:R,onChange:J=>j(J.target.checked)}),"Stop on runner failure"]}),p.jsx("p",{className:`text-xs ${ge}`,children:"Runner failure means transport/script/test failure. HTTP 4xx/5xx alone does not fail an item."})]}),L&&p.jsxs("div",{className:"grid gap-2 sm:grid-cols-5",children:[p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Progress"}),p.jsxs("strong",{children:[L.completed," / ",L.total]})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Passed"}),p.jsx("strong",{className:"text-green-600",children:L.passed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Failed"}),p.jsx("strong",{className:"text-red-600",children:L.failed})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Cancelled"}),p.jsx("strong",{children:L.cancelled})]}),p.jsxs("div",{className:"rounded-md border px-3 py-2 text-sm",children:[p.jsx("div",{className:ge,children:"Run"}),p.jsx("strong",{children:L.stopped?"Stopped":"Complete"})]})]}),p.jsxs("section",{className:"space-y-3","aria-labelledby":"api-client-runner-order-heading",children:[p.jsxs("div",{children:[p.jsx("h3",{id:"api-client-runner-order-heading",className:"font-semibold",children:"Execution order"}),p.jsx("p",{className:`text-xs ${ge}`,children:"Requests execute sequentially in saved-request order. Folder runs include descendant folders; this list is the exact order that will run."})]}),C.map((J,oe)=>{const he=G[J.id]||{status:"pending"},Se=he.item?.outcome.result,T=he.item?.outcome.scriptTests||[],z=T.filter(ne=>ne.passed).length,me=Se?.status!==void 0&&Se.status>=400;return p.jsxs("div",{"data-runner-request-id":J.id,className:`rounded-lg border p-3 ${q}`,children:[p.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[p.jsxs("div",{className:"min-w-0",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[p.jsx("span",{className:`text-xs ${ge}`,children:oe+1}),p.jsx("span",{className:"font-mono font-bold text-blue-600",children:J.request.method.toUpperCase()}),p.jsx("span",{className:"font-medium",children:J.name})]}),p.jsx("div",{className:`mt-1 text-xs ${ge}`,children:VM(t,J)}),p.jsx("div",{className:"mt-1 truncate font-mono text-xs",title:J.request.url,children:J.request.url})]}),p.jsxs("div",{className:"flex shrink-0 flex-wrap items-center gap-2 text-xs",children:[he.status==="running"&&p.jsx(JA,{className:"h-4 w-4 animate-spin"}),he.status==="passed"&&p.jsx(oa,{className:"h-4 w-4 text-green-600"}),he.status==="failed"&&p.jsx(FA,{className:"h-4 w-4 text-red-600"}),p.jsx("span",{children:FM(he)}),Se?.status!==void 0&&p.jsxs("span",{className:me?"text-amber-600":ge,children:["HTTP ",Se.status]}),Se?.responseTime!==void 0&&p.jsxs("span",{className:ge,children:[p.jsx(kd,{className:"mr-1 inline h-3.5 w-3.5"}),Se.responseTime," ms"]})]})]}),T.length>0&&p.jsxs("div",{className:`mt-2 text-xs ${T.some(ne=>!ne.passed)?"text-red-600":ge}`,children:[z,"/",T.length," tests passed"]}),he.item?.outcome.scriptError&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.scriptError}),he.item?.outcome.error&&!he.item.cancelled&&p.jsx("div",{className:"mt-2 text-xs text-red-600",children:he.item.outcome.error}),he.item?.historyEntryId&&p.jsx("button",{type:"button",className:"mt-2 text-xs font-medium text-blue-600 underline underline-offset-2","aria-label":`Open history for ${J.name}`,onClick:()=>v(he.item?.historyEntryId,he.item?.outcome.result?L?.runId:void 0),children:"Inspect history"})]},J.id)}),C.length===0&&p.jsx("div",{className:`rounded-lg border px-4 py-8 text-center text-sm ${ge}`,children:"There are no saved requests in this run scope yet."})]})]})})};function T1(t){return`flexdoc:api-client-ui:${encodeURIComponent(t)}`}function j1(t,e){const n=e??(typeof window<"u"?window.localStorage:void 0);if(!n)return{version:1};try{const r=n.getItem(T1(t));if(!r)return{version:1};const s=JSON.parse(r);return s.version!==1?{version:1}:s.sidebarCollapsed!==void 0&&typeof s.sidebarCollapsed!="boolean"?{version:1}:s.requestTab!==void 0&&!["params","headers","authorization","body","scripts"].includes(s.requestTab)?{version:1}:s.scriptTab!==void 0&&!["pre-request","tests"].includes(s.scriptTab)?{version:1}:s.theme!==void 0&&!["light","dark"].includes(s.theme)?{version:1}:{version:1,...typeof s.sidebarCollapsed=="boolean"?{sidebarCollapsed:s.sidebarCollapsed}:{},...typeof s.requestTab=="string"?{requestTab:s.requestTab}:{},...typeof s.scriptTab=="string"?{scriptTab:s.scriptTab}:{},...typeof s.theme=="string"?{theme:s.theme}:{}}}catch{return{version:1}}}function Ua(t,e,n){const r=typeof window<"u"?window.localStorage:void 0;if(r)try{const s=j1(t,r);r.setItem(T1(t),JSON.stringify({...s,...e,version:1}))}catch{}}function YM(t){return{method:t?.method||"GET",url:t?.url||"",query:t?.query?.map(e=>({...e}))||[],headers:t?.headers?.map(e=>({...e}))||[],body:t?.body||"",contentType:t?.contentType||"application/json",bodyMode:t?.bodyMode,urlencoded:t?.urlencoded?.map(e=>({...e})),formData:t?.formData?.map(e=>({...e})),binary:t?.binary?{...t.binary}:void 0,graphql:t?.graphql?{...t.graphql}:void 0,hostExecution:t?.hostExecution?{...t.hostExecution}:void 0,auth:t?.auth?t.auth.type==="oauth2"?{...t.auth,scopes:t.auth.scopes?[...t.auth.scopes]:void 0}:{...t.auth}:{type:"inherit"}}}function E1(t,e){return ha(t)!=="none"?"body":e.preRequest.trim()||e.tests.trim()?"scripts":t.auth&&t.auth.type!=="none"&&t.auth.type!=="inherit"?"authorization":(t.headers||[]).some(n=>n.enabled!==!1&&n.key.trim())?"headers":"params"}function cp(t){return t.tests.trim()&&!t.preRequest.trim()?"tests":"pre-request"}function O1(t,e){return JSON.stringify({request:t,scripts:Sn(e)},(n,r)=>typeof File<"u"&&r instanceof File?{name:r.name,size:r.size,type:r.type,lastModified:r.lastModified}:r)}function KM(t,e){return!!t.url.trim()||!!t.body?.trim()||!!t.query?.some(n=>n.key.trim()||n.value.trim())||!!t.headers?.some(n=>n.key.trim()||n.value.trim())||!!e.preRequest.trim()||!!e.tests.trim()}const M1=({initialRequest:t,initialScripts:e,initialRequestTab:n,initialScriptTab:r,theme:s="light",persistenceKey:a="default",pageMode:c=!1,manageTheme:u=!0,handoff:f,activeEnvironmentId:h,onActiveEnvironmentIdChange:g,onChromeStateChange:b,onRequestChange:v,onDraftChange:w,onScriptsChange:A,onRequestTabChange:C,onScriptTabChange:E,onExecutionStart:D,onExecutionComplete:O,variables:j={},environmentVariables:R={},onCollectionChanges:_,onEnvironmentChanges:L,...M})=>{const G=YM(t),Y=Sn(e),B=nl(),K=a===!1?{}:j1(a),[ee,be]=I.useState(G),[ce,ge]=I.useState(G),[q,J]=I.useState(Y),[oe,he]=I.useState(Y),[Se,T]=I.useState(M.initialServerUrl),[z,me]=I.useState(0),[ne,Ce]=I.useState(n||K.requestTab||"params"),[Re,qe]=I.useState(r||K.scriptTab||cp(Y)),[He,Je]=I.useState("request"),[Be,dt]=I.useState({}),[At,yt]=I.useState(),[Ge,Q]=I.useState(B),[re,ve]=I.useState(B.collections[0]?.id),[Ne,$e]=I.useState(""),We=I.useRef(B.collections[0]?.id),vt=I.useRef(void 0),[ti,Tn]=I.useState(a===!1),[ft,ni]=I.useState(K.sidebarCollapsed??!1),[Vn,qn]=I.useState(K.theme||s),kt=u?Vn:s;I.useEffect(()=>{if(a===!1)return;let Me=!1;return hy(a).then(Ze=>{Me||(Q(Ze),ve(Ze.collections[0]?.id),$e(""),Tn(!0))}).catch(()=>{Me||Tn(!0)}),()=>{Me=!0}},[a]);const x=my(a,Ge,ti),U=I.useMemo(()=>uy(Ge,re),[re,Ge]),pe=I.useMemo(()=>ff(Ge),[Ge]),ue=I.useMemo(()=>({...R,...pe}),[R,pe]),X=I.useMemo(()=>({...U,...j,...ue}),[U,ue,j]);I.useEffect(()=>{if(h===void 0)return;const Me=h||void 0;let Ze=!1;return queueMicrotask(()=>{Ze||Q($t=>$t.activeEnvironmentId===Me?$t:{...$t,activeEnvironmentId:Me})}),()=>{Ze=!0}},[h]);const k=I.useMemo(()=>O1(ce,oe),[ce,oe]),V=I.useMemo(()=>KM(ce,oe)&&!Ge.requests.some(Me=>O1(Me.request,Me.scripts)===k),[k,ce,oe,Ge.requests]);I.useEffect(()=>{b?.({environments:Ge.environments.map(({id:Me,name:Ze})=>({id:Me,name:Ze})),activeEnvironmentId:Ge.activeEnvironmentId,hasUnsavedRequest:V})},[V,b,Ge.activeEnvironmentId,Ge.environments]);const W=I.useCallback(Me=>cy(Ge,re,Ne||void 0,Me||{type:"none"}),[re,Ne,Ge]),we=I.useCallback(Me=>{ve(Me),$e("")},[]),F=Me=>{v?.(Me)},de=Me=>{ge(Ei(Me)),w?.(Ei(Me))},ae=Me=>{const Ze=Sn(Me);he(Ze),A?.(Ze)},Ae=Me=>{Ce(Me),a!==!1&&Ua(a,{requestTab:Me}),C?.(Me)},Ee=Me=>{qe(Me),a!==!1&&Ua(a,{scriptTab:Me}),E?.(Me)},Te=Me=>{const Ze=We.current||re;Q($t=>dy($t,Ze,Me)),_?.(Me)},Le=Me=>{Q(Ze=>hf(Ze,Me)),L?.(Me)},ze=()=>{We.current=re,vt.current=Ne||void 0,D?.()},Ve=Me=>{Q(Ze=>oy(Ze,{...Me,collectionId:We.current,folderId:vt.current})),O?.(Me)},Dt=(Me,Ze,$t,Bn)=>{Je("request");const ii=$t&&Ge.collections.some(Li=>Li.id===$t)?$t:void 0;ii&&ve(ii);const En=ii||re,_t=Bn&&Ge.folders.some(Li=>Li.id===Bn&&Li.collectionId===En)?Bn:"";$e(_t);const Yt=Ei(Me),Pn=Sn(Ze),Jr=E1(Yt,Pn),kl=cp(Pn);Ce(Jr),qe(kl),a!==!1&&Ua(a,{requestTab:Jr,scriptTab:kl}),be(Yt),ge(Yt),J(Pn),he(Pn),T(void 0),me(Li=>Li+1)};I.useEffect(()=>{if(!f)return;const Me=Ei(f.request),Ze=Sn(f.scripts),$t=f.requestTab||E1(Me,Ze),Bn=f.scriptTab||cp(Ze);let ii=!1;return queueMicrotask(()=>{ii||(Je("request"),be(Me),ge(Me),J(Ze),he(Ze),T(f.serverUrl),Ce($t),qe(Bn),me(En=>En+1))}),()=>{ii=!0}},[f]);const Fn=(Me,Ze)=>{ve(Me),$e(Ze||""),yt({collectionId:Me,folderId:Ze}),Je("runner")},jn=(Me,Ze)=>{dt({entryId:Me,runId:Ze}),Je("history")},Va=()=>ni(Me=>{const Ze=!Me;return a!==!1&&Ua(a,{sidebarCollapsed:Ze}),Ze}),qs=kt==="dark"?"border-gray-700 bg-gray-900/40 text-gray-100":"border-gray-200 bg-white text-gray-900",Bs=kt==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-300 bg-white text-gray-900";return p.jsxs("div",{className:`grid h-full min-h-0 min-w-0 ${c?"gap-0":"gap-4"} ${ft?"lg:grid-cols-[3.5rem_minmax(0,1fr)]":"lg:grid-cols-[19rem_minmax(0,1fr)]"}`,"data-api-client-workspace":!0,children:[p.jsxs("aside",{className:`min-h-0 min-w-0 overflow-y-auto border p-3 ${c?"rounded-none border-b-0 border-l-0 border-t-0":"rounded-xl"} ${qs}`,"data-api-client-workspace-sidebar":!0,"data-collapsed":ft?"true":"false",children:[p.jsx("div",{className:`mb-3 flex ${ft?"justify-center":"justify-end"}`,children:p.jsx("button",{type:"button",className:"inline-flex h-10 w-10 items-center justify-center rounded-md border","aria-label":ft?"Expand API Client sidebar":"Collapse API Client sidebar","aria-expanded":!ft,onClick:Va,children:ft?p.jsx(jd,{className:"h-4 w-4"}):p.jsx(Td,{className:"h-4 w-4"})})}),!ft&&p.jsxs("div",{className:"space-y-5",children:[x&&p.jsx(yf,{message:"FlexDoc could not save this workspace to browser storage. Recent changes and history will be lost when the page is closed. Clearing stored history usually frees enough space.",showCapabilities:!1,warning:!0,theme:kt,label:"API Client storage status"}),p.jsx(UM,{onWorkspaceChange:Q,onSelectedCollectionChange:we,theme:kt}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(yM,{workspace:Ge,onWorkspaceChange:Q,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(gM,{request:ce,scripts:oe,onLoadRequest:Dt,onSelectedCollectionChange:we,onSelectedFolderChange:$e,onRunCollection:Me=>Fn(Me),onRunFolder:(Me,Ze)=>Fn(Me,Ze),selectedCollectionId:re,selectedFolderId:Ne,workspace:Ge,onWorkspaceChange:Q,hostExecution:M.hostExecution,theme:kt})}),p.jsx("div",{className:"border-t pt-4",children:p.jsx(vM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onViewAll:()=>jn(),theme:kt})})]})]}),p.jsxs("div",{className:"min-h-0 min-w-0 overflow-y-auto overscroll-contain",children:[p.jsxs("div",{className:`mb-3 flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2 text-xs ${qs}`,"data-api-client-toolbar":!0,children:[p.jsxs("label",{className:"flex items-center gap-2",children:[p.jsx("span",{children:M.messages?.environment||"Environment"}),p.jsxs("select",{"aria-label":M.messages?.environment||"API Client environment",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,value:Ge.activeEnvironmentId||"",onChange:Me=>{const Ze=Me.target.value||void 0;Q($t=>({...$t,activeEnvironmentId:Ze})),g?.(Ze)},children:[p.jsx("option",{value:"",children:M.messages?.noEnvironment||"No environment"}),Ge.environments.map(Me=>p.jsx("option",{value:Me.id,children:Me.name},Me.id))]})]}),p.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[u&&p.jsxs("button",{type:"button",className:`rounded-md border px-2 py-1 text-xs ${Bs}`,"aria-label":`${M.messages?.viewerTheme||"Theme"}: ${kt==="dark"?M.messages?.lightTheme||"Light":M.messages?.darkTheme||"Dark"}`,"aria-pressed":kt==="dark",onClick:()=>{const Me=kt==="dark"?"light":"dark";qn(Me),a!==!1&&Ua(a,{theme:Me})},children:[M.messages?.viewerTheme||"Theme",": ",kt==="dark"?M.messages?.darkTheme||"Dark":M.messages?.lightTheme||"Light"]}),He==="request"&&V&&p.jsx("span",{"aria-label":"Unsaved request changes",children:M.messages?.unsavedChanges||"Unsaved changes"})]})]}),He==="history"?p.jsx(SM,{workspace:Ge,onWorkspaceChange:Q,onLoadRequest:Dt,onBack:()=>Je("request"),initialEntryId:Be.entryId,initialRunId:Be.runId,theme:kt},`${Be.runId||""}:${Be.entryId||""}`):He==="runner"&&At?p.jsx(PM,{workspace:Ge,onWorkspaceChange:Q,collectionId:At.collectionId,folderId:At.folderId,theme:kt,credentials:M.credentials,requestInterceptor:M.requestInterceptor,hostExecution:M.hostExecution,externalVariables:j,externalEnvironmentVariables:R,onCollectionChanges:_,onEnvironmentChanges:L,onOpenHistory:jn,onBack:()=>Je("request")}):p.jsx(e1,{...M,initialRequest:ee,initialScripts:q,initialRequestTab:ne,initialScriptTab:Re,initialServerUrl:Se,theme:kt,resolveAuth:W,variables:X,collectionVariables:U,externalVariables:j,environmentVariables:ue,onCollectionChanges:Te,onEnvironmentChanges:Le,onDraftChange:de,onScriptsChange:ae,onRequestTabChange:Ae,onScriptTabChange:Ee,onExecutionStart:ze,onExecutionComplete:Ve,credentialStorage:Ge.credentialStorage||"remember",onCredentialStorageChange:Me=>Q(Ze=>({...Ze,credentialStorage:Me})),onRequestChange:F},z)]})]})};function tu(t){if(t!==void 0)return typeof t=="number"?`${t}px`:t}function GM(t,e){if(!e)return{};const n=e.colors||{},r=e.typography||{},s=e.sidebar||{};return{"--flexdoc-primary":n.primary?.main,"--flexdoc-text":n.text?.primary,"--flexdoc-text-muted":n.text?.secondary,"--flexdoc-border":t==="dark"?n.border?.dark:n.border?.light,"--flexdoc-sidebar-bg":t==="dark"?s.backgroundColorDark:s.backgroundColor,"--flexdoc-sidebar-text":t==="dark"?s.textColorDark:s.textColor,"--flexdoc-sidebar-active-text":t==="dark"?s.activeTextColorDark:s.activeTextColor,"--flexdoc-heading-font":r.headings?.fontFamily,"--flexdoc-heading-weight":r.headings?.fontWeight,"--flexdoc-code-font":r.code?.fontFamily,"--flexdoc-code-size":r.code?.fontSize,"--flexdoc-code-line-height":r.code?.lineHeight,"--flexdoc-code-color":r.code?.color,"--flexdoc-code-bg":r.code?.backgroundColor,fontFamily:r.fontFamily,fontSize:r.fontSize,lineHeight:r.lineHeight}}function R1(t,e){const n=e.replace(/^#/,"");if(!n)return null;const r=[];for(const[s,a]of Object.entries(t.paths))for(const c of In.getHttpMethods(a)){if(Wh(s,c)===n)return{path:s,method:c};k3(s,c)===n&&r.push({path:s,method:c})}return r.length===1?r[0]:null}function D1(){return typeof window>"u"?"docs":new URLSearchParams(window.location.search).get("view")==="api-client"?"api-client":"docs"}function up(t){if(typeof window>"u")return;const e=new URL(window.location.href);t==="api-client"?e.searchParams.set("view","api-client"):e.searchParams.delete("view"),window.history.replaceState(null,"",`${e.pathname}${e.search}${e.hash}`)}function _1(t,e){if(typeof document>"u"||typeof URL>"u")return"Downloads are unavailable in this environment.";try{const n=e==="yaml"?hk(t,{lineWidth:120,noRefs:!1}):JSON.stringify(t,null,2),r=new Blob([n],{type:e==="yaml"?"application/yaml;charset=utf-8":"application/json;charset=utf-8"}),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`openapi.${e==="yaml"?"yaml":"json"}`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(s);return}catch(n){const r=n instanceof Error?n.message:String(n);return`Unable to download ${e.toUpperCase()}: ${r}`}}function XM({logo:t,onHome:e}){const n=typeof t=="string"?{url:t}:t,r=typeof n.padding=="object"?`${tu(n.padding.vertical)||"0"} ${tu(n.padding.horizontal)||"0"}`:n.padding,s=p.jsx("img",{src:n.url,alt:n.alt||"API documentation logo",style:{maxHeight:tu(n.maxHeight)||"32px",maxWidth:tu(n.maxWidth)||"180px"}});return p.jsx("div",{className:`flex items-center ${n.containerClass||""}`,style:{backgroundColor:n.backgroundColor,padding:r},children:n.clickable===!1?s:p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:e,children:s})})}const JM=({spec:t,theme:e="light",manageTheme:n=!0,customStyles:r={},options:s={}})=>{const a=xk(t.info.title,typeof window>"u"?void 0:window.location.host),c=fa(a),u=s.tryIt?.apiClientPersistenceKey??ly(t.info.title,typeof window>"u"?void 0:window.location.host),f=D1(),[h,g]=I.useState(()=>typeof window>"u"?null:R1(t,window.location.hash)),[b,v]=I.useState(f),[w,A]=I.useState(f==="api-client"),[C,E]=I.useState(),D=I.useRef(0),[O,j]=I.useState({environments:[],hasUnsavedRequest:!1}),[R,_]=I.useState(void 0),[L,M]=I.useState(!1),[G,Y]=I.useState(!1),[B,K]=I.useState(!1),[ee,be]=I.useState(),[ce,ge]=I.useState(),[q,J]=I.useState(()=>({key:a,preferences:c})),oe=I.useRef(null),he=I.useRef(null),Se=I.useRef(null),T=s.runtimeIntelligence?.available===!0,z=s.runtimeIntelligence?.endpoint,me=T&&z&&ce?.endpoint===z?ce:void 0,ne=me?.snapshot,Ce=me?.error,Re=!!(T&&z&&!me),qe=I.useCallback(()=>K(!1),[]),He=q.key===a?q.preferences:fa(a),Je=n&&He.theme||e,Be=Je==="high-contrast"?"dark":Je,dt=He.expand,At=He.expandedTags??["default"],yt=He.sidebarCollapsed??!1,Ge=typeof s.theme=="object"?s.theme:void 0,Q=I.useMemo(()=>({...GM(Be,Ge),...r}),[Be,Ge,r]);I.useEffect(()=>{if(!T||!z)return;const F=new AbortController;return fetch(z,{credentials:"same-origin",signal:F.signal}).then(async de=>{if(!de.ok)throw new Error(`Runtime intelligence unavailable: HTTP ${de.status}`);return V3(await de.json())}).then(de=>ge({endpoint:z,snapshot:de})).catch(de=>{F.signal.aborted||ge({endpoint:z,error:de instanceof Error?de.message:String(de)})}),()=>F.abort()},[T,z]),I.useEffect(()=>{if(!s.customCss)return;const F=document.createElement("style");return F.dataset.flexdocCustomCss="true",F.textContent=s.customCss,document.head.appendChild(F),()=>F.remove()},[s.customCss]),I.useEffect(()=>{if(typeof window>"u")return;const F=()=>g(R1(t,window.location.hash)),de=()=>{const ae=D1();v(ae),ae==="api-client"&&A(!0)};return F(),de(),window.addEventListener("hashchange",F),window.addEventListener("popstate",de),()=>{window.removeEventListener("hashchange",F),window.removeEventListener("popstate",de)}},[t]),I.useEffect(()=>{if(!L||typeof document>"u")return;const F=document.body.style.overflow,de=he.current;document.body.style.overflow="hidden";const ae=oe.current,Ae=()=>Array.from(ae?.querySelectorAll('button:not([data-focus-trap-ignore]):not([disabled]), a[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')||[]);requestAnimationFrame(()=>Ae()[0]?.focus());const Ee=Te=>{if(Te.key==="Escape"){Te.preventDefault(),M(!1);return}if(Te.key!=="Tab")return;const Le=Ae();if(!Le.length)return;const ze=Le[0],Ve=Le[Le.length-1];Te.shiftKey&&document.activeElement===ze?(Te.preventDefault(),Ve.focus()):!Te.shiftKey&&document.activeElement===Ve&&(Te.preventDefault(),ze.focus())};return document.addEventListener("keydown",Ee),()=>{document.body.style.overflow=F,document.removeEventListener("keydown",Ee),de?.focus()}},[L]);const re=()=>{J({key:a,preferences:fa(a)})},ve=F=>{J(de=>{const ae=de.key===a?de.preferences:fa(a);return{key:a,preferences:{...ae,...F,version:1}}})},Ne=()=>requestAnimationFrame(()=>Se.current?.scrollTo({top:0,behavior:"auto"})),$e=(F,de)=>{g({path:F,method:de}),v("docs"),M(!1),up("docs"),typeof window<"u"&&(window.location.hash=Wh(F,de)),Ne()},We=()=>{if(g(null),v("docs"),M(!1),typeof window<"u"){const F=new URL(window.location.href);F.searchParams.delete("view"),F.hash="",window.history.replaceState(null,"",`${F.pathname}${F.search}`)}Ne()},vt=F=>{F&&(D.current+=1,E({id:D.current,request:F.request,scripts:F.scripts,requestTab:F.requestTab,scriptTab:F.scriptTab,serverUrl:F.serverUrl})),A(!0),v("api-client"),up("api-client")},ti=()=>{v("docs"),up("docs"),Ne()},Tn=()=>{const F=!yt;qo(a,"sidebarCollapsed",F),ve({sidebarCollapsed:F})},ft=tf(s.expand,s.expand===void 0?s.expandResponses:void 0),ni=dt===void 0?ft:tf(dt),Vn=F=>{qo(a,"expand",F),re()},qn=F=>{n&&(qo(a,"theme",F),re())},kt=F=>{qo(a,"expandedTags",F),ve({expandedTags:F})},x=I.useCallback(()=>{if(typeof document>"u")return;(b==="api-client"?document.querySelector('[data-api-client-page="api-client"]:not(.hidden)'):document.querySelector('[data-flexdoc-docs-view="docs"]:not(.hidden)'))?.querySelector('[data-api-client-send="true"]:not([disabled])')?.click()},[b]),U=L3(Be,"border-gray-200 bg-white text-gray-600","border-gray-700 bg-gray-800 text-gray-300"),pe=Be==="dark"?"bg-gray-900 text-gray-100":"bg-gray-50 text-gray-900",ue=Be==="dark"?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-900",X=s.messages,k=(F=!1)=>p.jsx("button",{type:"button","data-flexdoc-floating-control":F?"settings":void 0,className:F?`fixed bottom-4 right-4 z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md border","aria-label":X?.openSettings||"Open settings","aria-expanded":G,onClick:()=>Y(!0),children:p.jsx(nk,{className:"h-5 w-5"})}),V=(F=!1)=>T?p.jsxs("button",{type:"button","data-flexdoc-floating-control":F?"runtime":void 0,className:F?`fixed bottom-4 right-[4.25rem] z-40 inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg ${ue}`:"inline-flex h-11 min-w-11 items-center justify-center gap-2 rounded-md border px-2 text-sm sm:px-3",onClick:()=>K(!0),"aria-label":X?.openRuntime||"Open runtime intelligence","aria-expanded":B,children:[p.jsx(Lg,{className:"h-4 w-4"}),!F&&p.jsx("span",{className:"hidden sm:inline",children:ne?`Runtime ${ne.summary.matched}/${ne.summary.documented}`:Re?"Runtime…":"Runtime"})]}):null,W=(F=!1)=>p.jsx("button",{ref:he,type:"button","data-flexdoc-floating-control":F?"navigation":void 0,"data-flexdoc-mobile-nav-trigger":F?"floating":"topbar",className:F?`fixed left-4 top-4 z-[65] pointer-events-auto inline-flex h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:hidden ${ue}`:"inline-flex h-11 w-11 items-center justify-center rounded-md lg:hidden","aria-label":X?.apiNavigation||"Open API navigation","aria-expanded":L,onClick:()=>M(!0),children:p.jsx(ZA,{className:"h-5 w-5"})}),we=p.jsx(pk,{spec:t,onEndpointSelect:$e,theme:Be,selectedEndpoint:h||void 0,expandedTags:At,onExpandedTagsChange:kt,messages:X});return p.jsxs("div",{lang:s.locale,className:`flexdoc-root flex h-full min-h-0 flex-col ${pe}`,style:Q,"data-theme":Je,"data-flexdoc-view":b,children:[!s.hideTopbar&&p.jsx("header",{className:`z-30 flex flex-wrap min-h-14 shrink-0 items-center gap-3 border-b px-3 sm:px-5 ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-200 bg-white"}`,children:b==="api-client"?p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button",className:"inline-flex min-h-11 items-center gap-2 rounded-md border px-3 text-sm",onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back to operation"]}),p.jsx("div",{className:"min-w-0 flex-1 truncate font-semibold",children:X?.apiClient||"API Client"}),p.jsxs("label",{className:"flex shrink-0 items-center gap-1 text-xs sm:gap-2",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"10rem"},className:`rounded-md border px-2 py-1.5 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"shrink-0 text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"}),k()]}):p.jsxs(p.Fragment,{children:[W(),p.jsx("button",{type:"button",className:"hidden h-11 w-11 items-center justify-center rounded-md border lg:inline-flex","aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.logo?p.jsx(XM,{logo:s.logo,onHome:We}):p.jsx("button",{type:"button","aria-label":"Documentation home",onClick:We,children:p.jsx(tM,{})}),p.jsxs("div",{className:"min-w-0 flex-1",children:[p.jsx("div",{className:"truncate font-semibold",children:t.info.title}),!s.hideHostname&&t.servers?.[0]?.url&&p.jsx("div",{className:"truncate text-xs opacity-60",children:t.servers[0].url})]}),V(),h&&p.jsx("button",{type:"button",className:"hidden shrink-0 rounded-md border px-3 py-2 text-sm md:inline-flex","aria-label":X?.printOperation||"Print operation",onClick:()=>{typeof window<"u"&&window.print()},children:X?.printOperation||"Print operation"}),!s.hideDownloadButton&&p.jsxs("div",{className:"flex shrink-0 items-center gap-1","aria-label":"Download OpenAPI specification",children:[p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"json")),children:"JSON"}),p.jsx("button",{type:"button",className:"rounded-md border px-2 py-2 text-xs sm:px-3 sm:text-sm",onClick:()=>be(_1(t,"yaml")),children:"YAML"})]}),k()]})}),s.hideTopbar&&b==="docs"&&W(!0),s.hideTopbar&&b==="docs"&&V(!0),s.hideTopbar&&k(!0),s.hideTopbar&&b==="docs"&&p.jsx("button",{type:"button","data-flexdoc-floating-control":"desktop-navigation",className:`fixed left-4 top-4 z-40 hidden h-11 w-11 items-center justify-center rounded-full border shadow-lg lg:inline-flex ${ue}`,"aria-label":yt?"Expand API navigation sidebar":"Collapse API navigation sidebar","aria-expanded":!yt,onClick:Tn,children:yt?p.jsx(jd,{className:"h-5 w-5"}):p.jsx(Td,{className:"h-5 w-5"})}),s.hideTopbar&&b==="api-client"&&p.jsxs(p.Fragment,{children:[p.jsxs("button",{type:"button","data-flexdoc-floating-control":"api-client-back",className:`fixed left-4 top-4 z-[65] inline-flex min-h-11 items-center gap-2 rounded-full border px-3 shadow-lg ${ue}`,onClick:ti,children:[p.jsx(_o,{className:"h-4 w-4"}),X?.backToOperation||"Back"]}),p.jsxs("div",{"data-flexdoc-floating-control":"api-client-status",className:`fixed right-4 top-4 z-[65] flex items-center gap-2 rounded-full border px-2 py-1.5 shadow-lg ${ue}`,style:{maxWidth:"calc(100vw - 8rem)"},children:[p.jsxs("label",{className:"flex min-w-0 items-center gap-1 text-xs",children:[p.jsx("span",{className:"sr-only",children:X?.environment||"Environment"}),p.jsxs("select",{"aria-label":X?.environment||"API Client environment",style:{maxWidth:"8rem"},className:`rounded-md border px-2 py-1 text-xs ${Be==="dark"?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"}`,value:R??O.activeEnvironmentId??"",onChange:F=>_(F.target.value||null),children:[p.jsx("option",{value:"",children:X?.noEnvironment||"No environment"}),O.environments.map(F=>p.jsx("option",{value:F.id,children:F.name},F.id))]})]}),O.hasUnsavedRequest&&p.jsx("span",{className:"truncate text-xs font-medium","aria-label":X?.unsavedChanges||"Unsaved request changes",children:X?.unsavedChanges||"Unsaved changes"})]})]}),p.jsxs("div",{className:"relative flex min-h-0 flex-1 overflow-hidden",children:[p.jsxs("div",{"data-flexdoc-docs-view":"docs",className:`${b==="docs"?"flex":"hidden"} min-h-0 min-w-0 flex-1`,children:[p.jsx("aside",{className:`hidden min-h-0 shrink-0 overflow-hidden transition-[width] duration-200 motion-reduce:transition-none lg:block ${yt?"w-14":"w-80"}`,"data-docs-sidebar":!0,"data-collapsed":yt?"true":"false",style:{background:"var(--flexdoc-sidebar-bg)",color:"var(--flexdoc-sidebar-text)"},children:!yt&&we}),p.jsxs("main",{ref:Se,"data-flexdoc-main-scroll":!0,className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain",children:[h?p.jsx(j3,{spec:t,path:h.path,method:h.method,theme:Be,options:s,defaultExpandedSections:ni,runtimeSnapshot:ne,onOpenInApiClient:vt}):p.jsx(R3,{spec:t,onEndpointSelect:$e,theme:Be}),p.jsx(_3,{footerClasses:U,footer:s.footer})]})]}),w&&p.jsx("div",{"data-api-client-page":"api-client",className:`${b==="api-client"?"block":"hidden"} min-h-0 min-w-0 flex-1 overflow-hidden`,children:p.jsx(M1,{pageMode:!0,manageTheme:!1,theme:Be,messages:X,persistenceKey:u,handoff:C,activeEnvironmentId:R,onActiveEnvironmentIdChange:F=>_(F??null),onChromeStateChange:F=>{j(F),_(de=>de===void 0?F.activeEnvironmentId??null:de)},credentials:s.tryIt?.credentials||"same-origin",requestInterceptor:s.tryIt?.requestInterceptor,hostExecution:s.tryIt?.hostExecution,serverOptions:t.servers||[]})})]}),L&&p.jsxs("div",{ref:oe,className:"fixed inset-0 z-[70] lg:hidden",role:"dialog","aria-modal":"true","aria-label":X?.apiNavigation||"API navigation",children:[p.jsx("button",{type:"button",tabIndex:-1,"data-focus-trap-ignore":!0,"aria-label":"Close navigation backdrop",className:"absolute inset-0 bg-black/40",onClick:()=>M(!1)}),p.jsxs("aside",{className:`absolute inset-y-0 left-0 flex w-[min(88vw,22rem)] flex-col shadow-2xl ${Be==="dark"?"bg-gray-900":"bg-white"}`,children:[p.jsxs("div",{className:"flex h-14 items-center justify-between border-b px-4",children:[p.jsx("span",{className:"font-semibold",children:X?.apiNavigation||"API navigation"}),p.jsx("button",{type:"button",className:"inline-flex h-11 w-11 items-center justify-center rounded-md","aria-label":X?.closeApiNavigation||"Close API navigation",onClick:()=>M(!1),children:p.jsx(Od,{className:"h-5 w-5"})})]}),p.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto",children:we})]})]}),ee&&p.jsx("div",{role:"alert",className:`fixed bottom-4 left-1/2 z-[90] max-w-[min(92vw,40rem)] -translate-x-1/2 rounded-lg border px-4 py-3 text-sm shadow-xl ${Be==="dark"?"border-red-800 bg-red-950 text-red-100":"border-red-300 bg-white text-red-700"}`,onClick:()=>be(void 0),children:X?.downloadFailed||ee}),p.jsx(Z3,{open:B&&T,theme:Be,loading:Re,error:Ce,snapshot:ne,onClose:qe,onEndpointSelect:$e,messages:X}),p.jsx(K3,{spec:t,theme:Be,messages:X,onEndpointSelect:$e,onHome:We,onOpenSettings:()=>Y(!0),onOpenApiClient:()=>vt(),onOpenRuntime:T?()=>K(!0):void 0,onSendCurrent:x}),p.jsx(Q3,{open:G,theme:Be,hostTheme:e,manageTheme:n,viewerTheme:He.theme,viewerExpand:dt,effectiveExpandedSections:ni,messages:X,onThemeChange:qn,onExpandChange:Vn,onClose:()=>Y(!1)})]})},dp="x-flexdoc-external-documents";function QM(t){if(typeof fetch!="function")throw new Error("No document loader is available in this environment");return fetch(t).then(async e=>{if(!e.ok)throw new Error(`Failed to load OpenAPI reference ${t}: ${e.status}`);const n=await e.text();return Ii.parseSpec(n).catch(()=>{try{return JSON.parse(n)}catch{throw new Error(`Reference document is not valid JSON/YAML: ${t}`)}})})}function WM(t,e){if(t.startsWith("#"))return{documentUri:e,pointer:t};const n=new URL(t,e),r=n.hash||"#";return n.hash="",{documentUri:n.toString(),pointer:r}}function L1(t,e){const n=Ii.encodePointerToken(t);if(e==="#"||e==="")return`#/${dp}/${n}`;if(!e.startsWith("#/"))throw new Error(`Unsupported JSON Pointer reference: ${e}`);return`#/${dp}/${n}/${e.slice(2)}`}function q1(t){return JSON.parse(JSON.stringify(t))}async function ZM(t,e){const n=e.load||QM,r=new URL(e.baseUri).toString().replace(/#.*$/,""),s=q1(t),a={},c=new Map;async function u(g){if(g===r)return s;if(a[g])return a[g];if(c.has(g))return c.get(g);const b=Promise.resolve(n(g)).then(w=>q1(w));c.set(g,b);const v=await b;return a[g]=v,v}const f=new Set;async function h(g,b){if(f.has(b))return;f.add(b);async function v(w){if(!(!w||typeof w!="object")){if(Array.isArray(w)){for(const A of w)await v(A);return}if(typeof w.$ref=="string"){const A=WM(w.$ref,b);if(A.documentUri!==b){const C=await u(A.documentUri);w.$ref=A.documentUri===r?A.pointer:L1(A.documentUri,A.pointer),await h(C,A.documentUri)}else b!==r&&(w.$ref=L1(b,A.pointer))}for(const[A,C]of Object.entries(w))A!=="$ref"&&await v(C)}}await v(g)}return await h(s,r),Object.keys(a).length&&(s[dp]=a),s}async function eR(t,e){return ZM(t,e)}const nu="1",iu=new WeakMap;function tR(t){return JSON.parse(JSON.stringify(t))}function fp(t,e={}){const n=tR(t);if(e.title&&(n.info.title=e.title),e.description&&(n.info.description=e.description),e.altDescription&&!n.info.description&&(n.info.description=e.altDescription),e.version&&(n.info.version=e.version),!e.tagGroups?.length)return n;const r=new Map;for(const c of e.tagGroups)for(const u of c.tags)r.set(u,c.name);const s={},a=new Set(["get","post","put","delete","patch","options","head","trace"]);for(const[c,u]of Object.entries(n.paths)){const f={};let h=!1;for(const[g,b]of Object.entries(u)){if(!a.has(g)){f[g]=b;continue}const v=b,w=(v?.tags||[]).filter(A=>r.has(A)).map(A=>r.get(A));!w.length||!v||(f[g]={...v,tags:Array.from(new Set(w))},h=!0)}h&&(s[c]=f)}return n.paths=s,n.tags=e.tagGroups.map(c=>({name:c.name})),n}function nR(t){return typeof t.theme=="string"?t.theme:typeof document<"u"&&document.documentElement.classList.contains("dark")?"dark":"light"}function iR(t){if(typeof document>"u"||!t.favicon)return;const e=document.querySelector('link[rel~="icon"]'),n=e||document.createElement("link");n.rel="icon",n.href=t.favicon,e||document.head.appendChild(n)}function B1(t,e){const n=iu.get(t);n&&n.unmount();const r=$A.createRoot(t);return iu.set(t,r),r.render(e),()=>{iu.get(t)===r&&iu.delete(t),r.unmount()}}function $1(t,e,n){return iR(n),B1(t,p.jsx(JM,{spec:fp(e,n),theme:nR(n),options:n}))}function I1(t,e){const n={contractVersion:nu,...e.options||{}};return $1(t,e.spec,n)}function H1(t,e={}){return B1(t,p.jsx(M1,{...e}))}async function z1(t,e){const n={contractVersion:nu,...e.options||{}},r=e.baseUri?await eR(e.spec,{baseUri:e.baseUri,load:e.documentLoader}):e.spec;return $1(t,r,n)}return typeof window<"u"&&(window.FlexDocStandalone={mount:I1,mountAsync:z1,mountApiClient:H1,prepareSpec:fp,contractVersion:nu}),As.FLEXDOC_CONTRACT_VERSION=nu,As.mountApiClient=H1,As.mountFlexDoc=I1,As.mountFlexDocAsync=z1,As.prepareSpec=fp,Object.defineProperty(As,Symbol.toStringTag,{value:"Module"}),As})({}); //# sourceMappingURL=flexdoc.standalone.js.map diff --git a/docs/runtime-intelligence.md b/docs/runtime-intelligence.md index c84636e5..11d5bc7c 100644 --- a/docs/runtime-intelligence.md +++ b/docs/runtime-intelligence.md @@ -148,7 +148,7 @@ The Node Runtime Intelligence snapshot can include one backend-produced `validat The four finding codes in this cut are: -- `runtime.operation-undocumented` — the running backend positively exposes an operation that OpenAPI does not document. Severity: `error`. The finding names the method and path. This is runtime evidence only and is not clickable as a spec operation. Because it is an error, the derived status is `fail`, and `flexdoc validate` exits `1` under the default policy. +- `runtime.operation-undocumented` — the running backend positively exposes an operation that OpenAPI does not document. Severity: `error` when discovery is complete, `warning` when discovery is partial, matching the other findings that must not treat an incomplete inventory as authoritative. The finding names the method and path and opens that registered route. It is not an OpenAPI operation. When discovery is complete the derived status is `fail`, and `flexdoc validate` exits `1` under the default policy. Set `runtimeIntelligence.acknowledgedUndocumented` to method/path pairs that are intentionally absent from OpenAPI; those operations are omitted from this finding. - `runtime.operation-unobserved` — OpenAPI documents an operation that runtime discovery did not observe. Severity: `error` when discovery is complete, `info` when discovery is partial. - `runtime.method-mismatch` — the same wire-equivalent path exists in both sources but under different HTTP methods. Severity: `error` when discovery is complete, `warning` when partial. The finding carries an expected documented method so the renderer can navigate to the spec operation. - `runtime.duplicate-operation` — the host exposes multiple registrations for one wire-equivalent method/path. Severity: `warning`. In 3.1 this is an explicitly supported/verified claim for Express (including Nest-on-Express) and Hono. Fastify participates in the other validation checks, but exact duplicate-registration reporting is not claimed for Fastify in this cut. diff --git a/e2e/runtime-intelligence.spec.cjs b/e2e/runtime-intelligence.spec.cjs index 85ebf8f9..144e6f09 100644 --- a/e2e/runtime-intelligence.spec.cjs +++ b/e2e/runtime-intelligence.spec.cjs @@ -34,6 +34,8 @@ test('runtime panel remains accessible with a hidden topbar and behaves as a mod await expect(dialog.getByLabel('Close runtime intelligence panel')).toBeFocused(); await expect.poll(() => page.evaluate(() => document.body.style.overflow)).toBe('hidden'); + await page.keyboard.press('Tab'); + await expect(dialog.getByRole('button', { name: 'Open runtime route POST /internal/reindex' })).toBeFocused(); await page.keyboard.press('Tab'); await expect(dialog.getByLabel('Close runtime intelligence panel')).toBeFocused(); await page.keyboard.press('Escape'); diff --git a/examples/javascript-express/README.md b/examples/javascript-express/README.md index a16e77ee..8e51b73c 100644 --- a/examples/javascript-express/README.md +++ b/examples/javascript-express/README.md @@ -2,7 +2,7 @@ This is the primary backend-native FlexDoc 3.1 showcase. Express serves the shared OpenAPI 3.1 contract, while FlexDoc runs inside the same backend and exposes the completed documentation/API Client surface plus live Runtime Intelligence. -The example intentionally registers `GET /internal/health` without documenting it. Open **Runtime** in FlexDoc to see a genuine implemented-but-undocumented route alongside the matched OpenAPI operations. That is the kind of backend knowledge a spec-only renderer cannot provide. +The example registers `GET /internal/health` without documenting it, and lists that operation in `runtimeIntelligence.acknowledgedUndocumented`. Contract validation stays green. The route stays on the snapshot's `routes` array. The Runtime panel shows findings rather than that array, so an acknowledged route does not appear there. The renderer also demonstrates the completed documentation/API Client surface: persisted viewer preferences, deep links, keyboard command palette, mobile navigation, JSON/YAML download, Basic/Advanced Try It, handoff to the sibling API Client page, environments, scripts, the CodeMirror-backed editor, response inspection, collection/history workflows, and code samples. diff --git a/examples/javascript-express/index.js b/examples/javascript-express/index.js index 095e65b9..828056dd 100644 --- a/examples/javascript-express/index.js +++ b/examples/javascript-express/index.js @@ -85,7 +85,10 @@ function buildApp() { requiredPropsFirst: true, sortPropsAlphabetically: true, showRequestHeaders: true, - runtimeIntelligence: true, + runtimeIntelligence: { + enabled: true, + acknowledgedUndocumented: [{ method: 'GET', path: '/internal/health' }], + }, expand: 'interactive', tryIt: { enabled: true, @@ -103,7 +106,7 @@ function buildApp() { } if (require.main === module) { - buildApp().listen(3000, () => console.log('Login: http://localhost:3000/example-login\nAPI: http://localhost:3000/pets\nDocs: http://localhost:3000/docs\nRuntime drift: GET /internal/health is intentionally undocumented')); + buildApp().listen(3000, () => console.log('Login: http://localhost:3000/example-login\nAPI: http://localhost:3000/pets\nDocs: http://localhost:3000/docs\nGET /internal/health is acknowledged as intentionally undocumented')); } module.exports = { buildApp }; diff --git a/examples/javascript-fastify/README.md b/examples/javascript-fastify/README.md index a9aa42ce..b137bcb7 100644 --- a/examples/javascript-fastify/README.md +++ b/examples/javascript-fastify/README.md @@ -2,7 +2,7 @@ This example serves the shared OpenAPI 3.1 showcase through Fastify and enables FlexDoc 3.1 Runtime Intelligence. FlexDoc reads Fastify's registered route tree at runtime, normalizes framework route syntax, and compares it with the exact OpenAPI document passed to the integration. -`GET /internal/health` is intentionally absent from the spec so the Runtime panel shows real drift. The normal renderer still exposes Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state, scripts, response inspection, keyboard workflows and code samples. +`GET /internal/health` is absent from the spec and listed in `runtimeIntelligence.acknowledgedUndocumented`, so contract validation stays green. The route stays on the snapshot's `routes` array. The Runtime panel shows findings rather than that array, so the acknowledged route does not appear there. The renderer still exposes Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state, scripts, response inspection, keyboard workflows and code samples. ```bash npm install diff --git a/examples/javascript-fastify/index.js b/examples/javascript-fastify/index.js index dba060c8..bd02c9dd 100644 --- a/examples/javascript-fastify/index.js +++ b/examples/javascript-fastify/index.js @@ -29,7 +29,10 @@ async function buildApp() { requiredPropsFirst: true, sortPropsAlphabetically: true, showRequestHeaders: true, - runtimeIntelligence: true, + runtimeIntelligence: { + enabled: true, + acknowledgedUndocumented: [{ method: 'GET', path: '/internal/health' }], + }, expand: 'interactive', tryIt: { enabled: true, defaultServer: 'http://localhost:3000', credentials: 'same-origin', apiClientPersistenceKey: 'flexdoc-fastify-3-showcase' }, codeSamples: { enabled: true, languages: ['curl', 'javascript', 'python', 'go', 'java'] }, @@ -45,7 +48,7 @@ async function main() { await app.listen({ port: 3000, host: '0.0.0.0' }); console.log('API: http://localhost:3000/pets'); console.log('Docs: http://localhost:3000/docs'); - console.log('Runtime drift: GET /internal/health is intentionally undocumented'); + console.log('GET /internal/health is acknowledged as intentionally undocumented'); } if (require.main === module) { diff --git a/examples/javascript-hono/README.md b/examples/javascript-hono/README.md index dea6095b..e4a19f1e 100644 --- a/examples/javascript-hono/README.md +++ b/examples/javascript-hono/README.md @@ -2,6 +2,6 @@ This example uses Hono `4.13.x` with the optional `setupHonoFlexDoc` integration. Its registry dependency is pinned to published `@prauga/flexdoc-backend` `3.3.0` for reproducible standalone installs, while repository CI validates against the backend package built from the current commit. Runtime Intelligence reads Hono's actual registered routes instead of inferring them from the OpenAPI document. -The contract documents `/health` and `/pets/{petId}`. `GET /internal/health` is deliberately registered only in Hono so the Runtime panel demonstrates implemented-but-undocumented drift. The docs surface also enables Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state and code samples. +The contract documents `/health` and `/pets/{petId}`. `GET /internal/health` is registered only in Hono and listed in `runtimeIntelligence.acknowledgedUndocumented`, so validation stays green. The route stays on the snapshot's `routes` array. The Runtime panel shows findings rather than that array, so the acknowledged route does not appear there. The docs surface also enables Basic/Advanced Try It, handoff to the sibling API Client page, persisted workspace state and code samples. The integration remains framework-native without making Hono a hard dependency of the core backend package. diff --git a/examples/javascript-hono/index.mjs b/examples/javascript-hono/index.mjs index e2d76ca3..5acad5a4 100644 --- a/examples/javascript-hono/index.mjs +++ b/examples/javascript-hono/index.mjs @@ -37,7 +37,7 @@ export const app = new Hono(); app.get('/health', (c) => c.json({ status: 'ok' })); app.get('/pets/:petId', (c) => c.json({ id: c.req.param('petId'), name: 'Miso' })); -// Intentionally omitted from the contract so Runtime Intelligence reports it as runtime-only. +// Absent from the contract and acknowledged so validation stays green. app.get('/internal/health', (c) => c.json({ status: 'internal-ok' })); setupHonoFlexDoc(app, '/docs', { @@ -46,7 +46,10 @@ setupHonoFlexDoc(app, '/docs', { title: 'FlexDoc Hono 3.0 showcase', description: 'Live Hono route discovery plus the canonical FlexDoc 3.0 renderer and API Client surface.', version: '3.0.0', - runtimeIntelligence: true, + runtimeIntelligence: { + enabled: true, + acknowledgedUndocumented: [{ method: 'GET', path: '/internal/health' }], + }, expand: 'interactive', tryIt: { enabled: true, diff --git a/packages/backend/src/contract-validation.test.ts b/packages/backend/src/contract-validation.test.ts index a3107f38..ef57d5d3 100644 --- a/packages/backend/src/contract-validation.test.ts +++ b/packages/backend/src/contract-validation.test.ts @@ -76,6 +76,33 @@ describe('runtime contract validation', () => { })]); }); + it('downgrades an undocumented route to a warning when discovery is partial', () => { + const result = validateRuntimeContract({ + documentedRoutes: [{ method: 'GET', path: '/pets' }], + runtimeRoutes: [{ method: 'POST', path: '/internal/reindex' }], + discoveryComplete: false, + }); + expect(result.status).toBe('warn'); + expect(result.findings[0]).toEqual(expect.objectContaining({ + code: 'runtime.operation-undocumented', + severity: 'warning', + })); + }); + + it('omits runtime operations the operator has acknowledged as undocumented', () => { + const result = validateRuntimeContract({ + documentedRoutes: [{ method: 'GET', path: '/pets' }], + runtimeRoutes: [ + { method: 'GET', path: '/pets' }, + { method: 'GET', path: '/internal/health' }, + ], + acknowledgedUndocumented: [{ method: 'GET', path: '/internal/health' }], + discoveryComplete: true, + }); + expect(result.status).toBe('pass'); + expect(result.findings).toEqual([]); + }); + it('reports duplicate host registrations that standalone OpenAPI tooling cannot observe', () => { const result = validateRuntimeContract({ documentedRoutes: [{ method: 'GET', path: '/pets/{petId}' }], diff --git a/packages/backend/src/contract-validation.ts b/packages/backend/src/contract-validation.ts index fabe2f1c..5afb346b 100644 --- a/packages/backend/src/contract-validation.ts +++ b/packages/backend/src/contract-validation.ts @@ -63,6 +63,7 @@ export interface ValidateRuntimeContractOptions { /** Normalized operations discovered from the running backend. */ runtimeRoutes: FlexDocContractRoute[]; /** Runtime operations that were registered more than once by the host framework. */ duplicateRuntimeRoutes?: FlexDocContractDuplicateRuntimeRoute[]; /** Whether route discovery is believed to cover the complete running application. */ discoveryComplete: boolean; + /** Runtime operations intentionally absent from OpenAPI. They are not reported as undocumented. */ acknowledgedUndocumented?: FlexDocContractRoute[]; } function routeShape(path: string): string { @@ -142,14 +143,15 @@ export function validateRuntimeContract(options: ValidateRuntimeContractOptions) }); } + const acknowledgedKeys = new Set((options.acknowledgedUndocumented || []).map(exactShapeKey)); for (const route of options.runtimeRoutes) { const shape = routeShape(route.path); if (methodMismatchShapes.has(shape)) continue; - if (documentedKeys.has(exactShapeKey(route))) continue; + if (documentedKeys.has(exactShapeKey(route)) || acknowledgedKeys.has(exactShapeKey(route))) continue; findings.push({ id: findingId('runtime.operation-undocumented', route.path, route.method), code: 'runtime.operation-undocumented', - severity: 'error', + severity: options.discoveryComplete ? 'error' : 'warning', location: { kind: 'operation', method: route.method.toUpperCase(), path: route.path }, message: `Runtime implements ${route.method.toUpperCase()} ${route.path}, but OpenAPI does not document that operation.`, expected: 'Operation is represented in OpenAPI', diff --git a/packages/backend/src/framework-adapters.ts b/packages/backend/src/framework-adapters.ts index 8fff1140..bcea2964 100644 --- a/packages/backend/src/framework-adapters.ts +++ b/packages/backend/src/framework-adapters.ts @@ -7,7 +7,7 @@ import { generateFlexDocHTML } from './template'; import { createHostExecutionState, publicHostExecutionOptions } from './host-execution'; import { hostExecutionRequestOrigin, runHostCookiesRoute, runHostExecutionRoute } from './host-execution-route'; import { createCachedFlexDocPage, matchesFlexDocEtag } from './page-cache'; -import { buildRuntimeIntelligenceSnapshot, discoverFastifyRoutes, runtimeIntelligenceEnabled } from './runtime-intelligence'; +import { acknowledgedUndocumentedRoutes, buildRuntimeIntelligenceSnapshot, discoverFastifyRoutes, runtimeIntelligenceEnabled } from './runtime-intelligence'; /** Minimal Express application surface required by `setupExpressFlexDoc`. */ export interface ExpressLikeApplication { @@ -177,6 +177,7 @@ function setupFastifyFlexDocInternal( const snapshot = buildRuntimeIntelligenceSnapshot({ spec: await resolvedSpec(), discovery: await discoverFastifyRoutes(app, normalizedPath), + acknowledgedUndocumented: acknowledgedUndocumentedRoutes(options.options?.runtimeIntelligence), serverOrigin, }); return reply diff --git a/packages/backend/src/hono-adapter.ts b/packages/backend/src/hono-adapter.ts index 594155f1..87c370c3 100644 --- a/packages/backend/src/hono-adapter.ts +++ b/packages/backend/src/hono-adapter.ts @@ -5,7 +5,7 @@ import { generateFlexDocHTML } from './template'; import { createHostExecutionState, publicHostExecutionOptions } from './host-execution'; import { hostExecutionRequestOrigin, runHostCookiesRoute, runHostExecutionRoute } from './host-execution-route'; import { createCachedFlexDocPage, matchesFlexDocEtag } from './page-cache'; -import { buildRuntimeIntelligenceSnapshot, discoverHonoRoutes, runtimeIntelligenceEnabled } from './runtime-intelligence'; +import { acknowledgedUndocumentedRoutes, buildRuntimeIntelligenceSnapshot, discoverHonoRoutes, runtimeIntelligenceEnabled } from './runtime-intelligence'; /** Minimal Hono request surface required by FlexDoc's adapter. */ export interface HonoLikeRequest { @@ -117,6 +117,7 @@ export function setupHonoFlexDoc( const snapshot = buildRuntimeIntelligenceSnapshot({ spec: await resolvedSpec(), discovery: discoverHonoRoutes(app, base), + acknowledgedUndocumented: acknowledgedUndocumentedRoutes(options.options?.runtimeIntelligence), serverOrigin, }); return context.body(JSON.stringify(snapshot), 200, { diff --git a/packages/backend/src/index.ts b/packages/backend/src/index.ts index 97318395..09ff242f 100644 --- a/packages/backend/src/index.ts +++ b/packages/backend/src/index.ts @@ -124,6 +124,6 @@ export type { FlexDocContractValidationSummary, ValidateRuntimeContractOptions, } from './contract-validation'; -export { buildRuntimeIntelligenceSnapshot, discoverExpressRoutes, discoverFastifyRoutes, discoverHonoRoutes, documentedOpenApiRoutes, nodeRuntimeMetadata, normalizeRuntimePath } from './runtime-intelligence'; +export { acknowledgedUndocumentedRoutes, buildRuntimeIntelligenceSnapshot, discoverExpressRoutes, discoverFastifyRoutes, discoverHonoRoutes, documentedOpenApiRoutes, nodeRuntimeMetadata, normalizeRuntimePath } from './runtime-intelligence'; export type { FlexDocRuntimeDiscovery, FlexDocRuntimeDuplicateRoute, FlexDocRuntimeIntelligenceSnapshot, FlexDocRuntimeMetadata, FlexDocRuntimeRoute } from './runtime-intelligence'; export type { HonoLikeApplication, HonoLikeContext } from './hono-adapter'; \ No newline at end of file diff --git a/packages/backend/src/interfaces.ts b/packages/backend/src/interfaces.ts index cd5c8e19..26e2448d 100644 --- a/packages/backend/src/interfaces.ts +++ b/packages/backend/src/interfaces.ts @@ -227,6 +227,7 @@ export interface FlexDocHostExecutionPublicOptions { /** Explicit Runtime Intelligence opt-in configuration. */ export interface FlexDocRuntimeIntelligenceOptions { /** Enable runtime route discovery and drift metadata for this documentation mount. */ enabled: true; + /** Runtime operations that are intentionally absent from OpenAPI and must not be reported as undocumented. */ acknowledgedUndocumented?: Array<{ method: string; path: string }>; } /** Runtime Intelligence endpoint metadata safe to serialize to the renderer. */ diff --git a/packages/backend/src/runtime-intelligence.test.ts b/packages/backend/src/runtime-intelligence.test.ts index 6388e25a..cc7e0cc0 100644 --- a/packages/backend/src/runtime-intelligence.test.ts +++ b/packages/backend/src/runtime-intelligence.test.ts @@ -139,6 +139,30 @@ describe('runtime intelligence', () => { expect(snapshot.runtime).toEqual({ name: 'node', version: 'v22.22.3', platform: 'linux', arch: 'x64' }); }); + it('omits acknowledged undocumented routes from drift and validation', () => { + const snapshot = buildRuntimeIntelligenceSnapshot({ + spec: { openapi: '3.1.0', paths: { '/pets': { get: {} } } }, + discovery: { + framework: 'express', + complete: true, + routes: [ + { method: 'GET', path: '/pets' }, + { method: 'GET', path: '/internal/health' }, + ], + }, + acknowledgedUndocumented: [{ method: 'GET', path: '/internal/health' }], + }); + expect(snapshot.routes).toEqual([ + { method: 'GET', path: '/internal/health' }, + { method: 'GET', path: '/pets' }, + ]); + expect(snapshot.runtimeOnly).toEqual([]); + expect(snapshot.summary).toEqual({ documented: 1, runtime: 1, matched: 1, runtimeOnly: 0, documentedOnly: 0 }); + expect(snapshot.summary.matched + snapshot.summary.runtimeOnly).toBe(snapshot.summary.runtime); + expect(snapshot.validation.status).toBe('pass'); + expect(snapshot.validation.findings).toEqual([]); + }); + it('feeds duplicate host registrations into contract validation', () => { const snapshot = buildRuntimeIntelligenceSnapshot({ spec: { openapi: '3.1.0', paths: { '/pets/{petId}': { get: {} } } }, diff --git a/packages/backend/src/runtime-intelligence.ts b/packages/backend/src/runtime-intelligence.ts index dd6d3198..5aaabc88 100644 --- a/packages/backend/src/runtime-intelligence.ts +++ b/packages/backend/src/runtime-intelligence.ts @@ -43,7 +43,7 @@ export interface FlexDocRuntimeDiscovery { /** Aggregate route counts in a Runtime Intelligence snapshot. */ export interface FlexDocRuntimeIntelligenceSummary { /** Number of documented OpenAPI operations. */ documented: number; - /** Number of runtime routes observed. */ runtime: number; + /** Runtime routes in the drift comparison. Equals `matched + runtimeOnly`. Acknowledged undocumented routes stay in `routes` and are excluded here. */ runtime: number; /** Number of wire-equivalent method/path matches between runtime and OpenAPI. */ matched: number; /** Number of runtime-only routes. */ runtimeOnly: number; /** Number of documented-only routes. */ documentedOnly: number; @@ -76,6 +76,20 @@ export function runtimeIntelligenceEnabled(value: boolean | FlexDocRuntimeIntell return value === true || (typeof value === 'object' && value?.enabled === true); } +/** + * Normalize operations an operator has accepted as intentionally absent from OpenAPI. + * @param value Runtime Intelligence configuration from the host integration. + * @returns Routes omitted from undocumented findings, or an empty list when none are acknowledged. + */ +export function acknowledgedUndocumentedRoutes(value: boolean | FlexDocRuntimeIntelligenceOptions | undefined): FlexDocRuntimeRoute[] { + if (!value || typeof value !== 'object' || !Array.isArray(value.acknowledgedUndocumented)) return []; + return uniqueSorted(value.acknowledgedUndocumented.flatMap((entry) => { + if (!entry || typeof entry.method !== 'string' || typeof entry.path !== 'string') return []; + const route = normalizedRoute(entry.method, entry.path); + return route ? [route] : []; + })); +} + /** * Normalize a framework route path for Runtime Intelligence comparisons. * @param value Framework route path or template. @@ -324,6 +338,7 @@ export interface FlexDocRuntimeIntelligenceSnapshotInput { /** Safe backend listener metadata. */ server?: FlexDocRuntimeServerMetadata; /** Explicit environment metadata; Node's `NODE_ENV` fallback is used when omitted. */ environment?: FlexDocRuntimeEnvironmentMetadata; /** Explicit runtime metadata; current Node process metadata is used when omitted. */ runtime?: FlexDocRuntimeMetadata; + /** Runtime operations intentionally absent from OpenAPI. */ acknowledgedUndocumented?: FlexDocRuntimeRoute[]; } /** @@ -336,8 +351,9 @@ export function buildRuntimeIntelligenceSnapshot(input: FlexDocRuntimeIntelligen const runtimeRoutes = uniqueSorted(input.discovery.routes); const documentedKeys = new Set(documented.map(contractRouteKey)); const runtimeKeys = new Set(runtimeRoutes.map(contractRouteKey)); + const acknowledgedKeys = new Set((input.acknowledgedUndocumented || []).map(contractRouteKey)); const matched = runtimeRoutes.filter((route) => documentedKeys.has(contractRouteKey(route))).length; - const runtimeOnly = runtimeRoutes.filter((route) => !documentedKeys.has(contractRouteKey(route))); + const runtimeOnly = runtimeRoutes.filter((route) => !documentedKeys.has(contractRouteKey(route)) && !acknowledgedKeys.has(contractRouteKey(route))); const documentedOnly = documented.filter((route) => !runtimeKeys.has(contractRouteKey(route))); const environment = input.environment || nodeEnvironmentMetadata(); const validation = validateRuntimeContract({ @@ -345,6 +361,7 @@ export function buildRuntimeIntelligenceSnapshot(input: FlexDocRuntimeIntelligen runtimeRoutes, duplicateRuntimeRoutes: input.discovery.duplicateRoutes, discoveryComplete: input.discovery.complete, + acknowledgedUndocumented: input.acknowledgedUndocumented, }); return { @@ -360,7 +377,7 @@ export function buildRuntimeIntelligenceSnapshot(input: FlexDocRuntimeIntelligen documentedOnly, summary: { documented: documented.length, - runtime: runtimeRoutes.length, + runtime: matched + runtimeOnly.length, matched, runtimeOnly: runtimeOnly.length, documentedOnly: documentedOnly.length, diff --git a/packages/backend/src/setup.ts b/packages/backend/src/setup.ts index b3a20901..6313e161 100644 --- a/packages/backend/src/setup.ts +++ b/packages/backend/src/setup.ts @@ -7,7 +7,7 @@ import * as https from 'https'; import { createHostExecutionState, publicHostExecutionOptions } from './host-execution'; import { hostExecutionRequestOrigin, readNodeRequestBody, runHostCookiesRoute, runHostExecutionRoute } from './host-execution-route'; import { createCachedFlexDocPage, matchesFlexDocEtag } from './page-cache'; -import { buildRuntimeIntelligenceSnapshot, discoverExpressRoutes, runtimeIntelligenceEnabled } from './runtime-intelligence'; +import { acknowledgedUndocumentedRoutes, buildRuntimeIntelligenceSnapshot, discoverExpressRoutes, runtimeIntelligenceEnabled } from './runtime-intelligence'; interface AppWithUse { use: ( @@ -174,6 +174,7 @@ export function setupFlexDoc( const snapshot = buildRuntimeIntelligenceSnapshot({ spec: await getSpec(), discovery: discoverExpressRoutes(app, normalizedPath), + acknowledgedUndocumented: acknowledgedUndocumentedRoutes(flexDocOptions?.runtimeIntelligence), serverOrigin, ...(localPort ? { server: { localPort } } : {}), }); diff --git a/packages/client/src/components/EndpointDetail.runtime-route.test.tsx b/packages/client/src/components/EndpointDetail.runtime-route.test.tsx new file mode 100644 index 00000000..cafed60e --- /dev/null +++ b/packages/client/src/components/EndpointDetail.runtime-route.test.tsx @@ -0,0 +1,51 @@ +// The repo-wide React mock returns the initial state on every render, so a +// stale useState value cannot be observed. This file uses real React. +jest.unmock('react'); + +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { EndpointDetail } from './EndpointDetail'; +import type { OpenAPISpec } from '../types/openapi'; +import type { FlexDocRuntimeIntelligenceSnapshot } from '../types/options'; + +jest.mock('./SchemaView', () => ({ SchemaView: () =>
})); +jest.mock('./CodeBlock', () => ({ CodeBlock: () =>
})); +jest.mock('./TryItApiClientWorkspace', () => ({ TryItApiClientWorkspace: () =>
})); + +const spec: OpenAPISpec = { + openapi: '3.1.0', + info: { title: 'Pets', version: '1.0.0' }, + paths: { '/pets': { get: { summary: 'List pets', responses: { '200': { description: 'ok' } } } } }, +}; + +const snapshot: FlexDocRuntimeIntelligenceSnapshot = { + framework: 'express', + runtime: { name: 'node', version: 'v22', platform: 'linux', arch: 'x64' }, + discoveryComplete: true, + routes: [{ method: 'POST', path: '/internal/reindex' }], + runtimeOnly: [{ method: 'POST', path: '/internal/reindex' }], + documentedOnly: [], + summary: { documented: 1, runtime: 1, matched: 0, runtimeOnly: 1, documentedOnly: 0 }, +}; + +describe('EndpointDetail runtime-only routes', () => { + it('opens a registered route that OpenAPI does not document', () => { + render(); + expect(screen.getByText('POST')).toBeInTheDocument(); + expect(screen.getByText('/internal/reindex')).toBeInTheDocument(); + expect(screen.getByText('The running service registers this operation. OpenAPI does not document it.')).toBeInTheDocument(); + }); + + it('keeps an unknown path as operation not found', () => { + render(); + expect(screen.getByText('Operation not found.')).toBeInTheDocument(); + }); + + it('renders a documented operation after a runtime-only route in the same instance', () => { + const { rerender } = render(); + expect(screen.getByText('The running service registers this operation. OpenAPI does not document it.')).toBeInTheDocument(); + rerender(); + expect(screen.queryByText('Operation not found.')).not.toBeInTheDocument(); + expect(screen.getByRole('heading', { name: 'List pets' })).toBeInTheDocument(); + }); +}); diff --git a/packages/client/src/components/EndpointDetail.tsx b/packages/client/src/components/EndpointDetail.tsx index 11483f7c..a8ff1f6c 100644 --- a/packages/client/src/components/EndpointDetail.tsx +++ b/packages/client/src/components/EndpointDetail.tsx @@ -67,11 +67,19 @@ export const EndpointDetail: React.FC = ({ spec, path, meth const [copiedLink, setCopiedLink] = useState(false); const codeTabsId = useId().replace(/:/g, ''); const codeTabRefs = useRef>>({}); - const initialBuiltRequest = useMemo(() => buildRequest(spec, path, method, initialRequestValues(spec, path, method)), [spec, path, method]); - const [sampleRequest, setSampleRequest] = useState(initialBuiltRequest); const pathItem = spec.paths[path]; const operation = pathItem?.[method.toLowerCase() as keyof typeof pathItem] as Operation | undefined; - const parameters = useMemo(() => parametersFor(spec, path, method), [spec, path, method]); + const initialBuiltRequest = useMemo(() => operation ? buildRequest(spec, path, method, initialRequestValues(spec, path, method)) : undefined, [operation, spec, path, method]); + const requestKey = `${method}:${path}`; + const [sampleRequestState, setSampleRequestState] = useState<{ key: string; request: typeof initialBuiltRequest }>(() => ({ + key: requestKey, + request: initialBuiltRequest, + })); + const sampleRequest = sampleRequestState.key === requestKey ? sampleRequestState.request : initialBuiltRequest; + const setSampleRequest = (request: NonNullable) => { + setSampleRequestState({ key: requestKey, request }); + }; + const parameters = useMemo(() => operation ? parametersFor(spec, path, method) : [], [operation, spec, path, method]); const messages = options.messages; useEffect(() => { @@ -79,7 +87,19 @@ export const EndpointDetail: React.FC = ({ spec, path, meth requestAnimationFrame(() => document.getElementById('tryIt-heading')?.scrollIntoView({ block: 'start' })); }, [deepLink.tryIt, method, path]); - if (!operation) return
Operation not found.
; + if (!operation) { + const registered = runtimeSnapshot?.runtimeOnly?.some((route) => route.path === path && route.method.toUpperCase() === method.toUpperCase()) + || runtimeSnapshot?.validation?.findings.some((finding) => finding.code === 'runtime.operation-undocumented' && finding.location.path === path && finding.location.method?.toUpperCase() === method.toUpperCase()); + if (!registered) return
{messages?.operationNotFound || 'Operation not found.'}
; + return
+
+ {method.toUpperCase()} + {path} +
+

{messages?.runtimeRouteUndocumented || 'The running service registers this operation. OpenAPI does not document it.'}

+
; + } + if (!sampleRequest) return
{messages?.operationNotFound || 'Operation not found.'}
; const muted = theme === 'dark' ? 'text-gray-400' : 'text-gray-600'; const card = theme === 'dark' ? 'border-gray-700 bg-gray-800/60' : 'border-gray-200 bg-white'; diff --git a/packages/client/src/components/RuntimeIntelligencePanel.test.tsx b/packages/client/src/components/RuntimeIntelligencePanel.test.tsx index 4530c5c2..f33e5767 100644 --- a/packages/client/src/components/RuntimeIntelligencePanel.test.tsx +++ b/packages/client/src/components/RuntimeIntelligencePanel.test.tsx @@ -61,15 +61,16 @@ describe('RuntimeIntelligencePanel', () => { expect(screen.getByText('production')).toBeInTheDocument(); }); - it('opens documented findings but never treats undocumented runtime routes as spec operations', () => { + it('opens a documented finding and a runtime-only finding as different kinds of route', () => { const select = jest.fn(); const close = jest.fn(); render(); fireEvent.click(screen.getByRole('button', { name: 'Open documented operation GET /missing' })); expect(select).toHaveBeenCalledWith('/missing', 'GET'); - expect(close).toHaveBeenCalledTimes(1); - expect(screen.queryByRole('button', { name: /POST \/internal\/reindex/ })).not.toBeInTheDocument(); + fireEvent.click(screen.getByRole('button', { name: 'Open runtime route POST /internal/reindex' })); + expect(select).toHaveBeenCalledWith('/internal/reindex', 'POST'); + expect(close).toHaveBeenCalledTimes(2); }); it('opens method-mismatch findings using an expected documented HTTP method', () => { diff --git a/packages/client/src/components/RuntimeIntelligencePanel.tsx b/packages/client/src/components/RuntimeIntelligencePanel.tsx index 7caed997..726654f9 100644 --- a/packages/client/src/components/RuntimeIntelligencePanel.tsx +++ b/packages/client/src/components/RuntimeIntelligencePanel.tsx @@ -114,7 +114,18 @@ export const RuntimeIntelligencePanel: React.FC = ({ open, theme, loading onClose(); } : undefined} /> : <> - + { + onEndpointSelect(route.path, route.method); + onClose(); + } : undefined} + />

{heading} ({result.findings.length})

{result.findings.length ?
{result.findings.map((finding) => { const documentedFinding = finding.code === 'runtime.operation-unobserved' || finding.code === 'runtime.method-mismatch'; - const canSelect = Boolean(onSelect && documentedFinding && finding.location.method); + const runtimeOnlyFinding = finding.code === 'runtime.operation-undocumented'; + const canSelect = Boolean(onSelect && finding.location.method && (documentedFinding || runtimeOnlyFinding)); + const openLabel = runtimeOnlyFinding + ? (messages?.openRuntimeRoute || 'Open runtime route') + : (messages?.openDocumentedOperation || 'Open documented operation'); const content = <>
{finding.severity.toUpperCase()}{finding.code}
{finding.message}
@@ -149,7 +164,7 @@ function ValidationFindings({ result, theme, messages, onSelect }: { result: Fle {finding.observed !== undefined &&
{messages?.validationObserved || 'Observed'}: {validationValue(finding.observed)}
}
} ; - return canSelect ? :
{content}
; + return canSelect ? :
{content}
; })}
:

{messages?.contractValidationPass || 'No contract mismatches detected.'}

}; } diff --git a/packages/client/src/types/options.ts b/packages/client/src/types/options.ts index 52bdcd3e..8589b9f8 100644 --- a/packages/client/src/types/options.ts +++ b/packages/client/src/types/options.ts @@ -174,7 +174,10 @@ export interface FlexDocMessages { /** Heading for documented routes not observed at runtime. */ documentedButNotObserved?: string; /** Empty-state copy when all documented routes are observed. */ everyDocumentedRouteObserved?: string; /** Status text shown when runtime and documented routes align. */ runtimeAligned?: string; - /** Action text for opening a runtime route's documentation when available. */ openRuntimeRoute?: string; + /** Action text for opening a runtime-registered route, including one OpenAPI does not document. */ openRuntimeRoute?: string; + /** Action text for opening a documented operation from a contract finding. */ openDocumentedOperation?: string; + /** Explains a route the running service registered and OpenAPI does not document. */ runtimeRouteUndocumented?: string; + /** Shown when the selected path is neither documented nor registered at runtime. */ operationNotFound?: string; /** Heading for structured runtime-vs-OpenAPI contract findings. */ contractValidation?: string; /** Status text shown when 3.1 contract validation has no findings. */ contractValidationPass?: string; /** Label preceding expected contract state in a finding. */ validationExpected?: string; @@ -239,7 +242,7 @@ export interface FlexDocRuntimeEnvironmentMetadata { /** Aggregate route counts in a Runtime Intelligence snapshot. */ export interface FlexDocRuntimeIntelligenceSummary { /** Number of HTTP operations present in the OpenAPI document. */ documented: number; - /** Number of routes discovered in the running backend. */ runtime: number; + /** Runtime routes in the drift comparison (`matched + runtimeOnly`). Acknowledged undocumented routes stay in `routes` and are excluded here. */ runtime: number; /** Number of routes observed in both OpenAPI and the running backend. */ matched: number; /** Number of runtime routes missing from OpenAPI. */ runtimeOnly: number; /** Number of OpenAPI operations not observed at runtime. */ documentedOnly: number;